문제

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

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top