Domanda

I want to run following query into Bigquery

SELECT table1.field1, COUNT(table1.fiels2)
FROM table1
GROUP BY table1.fiels1
ORDER BY COUNT(table1.fiels2)
DESC limit 10;

I am getting error Error: (L1:282): expression COUNT([metamx_magnetic_share.adops001.cookie], DESC) in ORDER BY is invalid

But same query I am successfully ran on Vertica.

Any kind of help/suggestion would be appreciated.

Thanks

È stato utile?

Soluzione

You can sort by an alias, but not a function, so try:

SELECT table1.field1, COUNT(table1.fiels2) as cnt
FROM table1
GROUP BY table1.fiels1
ORDER BY cnt
DESC limit 10;

The documentation is here.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top