Google Sheets query - Multiple “where” conditions with “group by” and “order by”

◇◆丶佛笑我妖孽 提交于 2020-12-13 05:50:00

问题


I'm trying to use multiple where conditions (2 conditions) with 'group by' and 'order by' statements inside a Google Sheets Query formula.

query(Sites!A:D,"select A,C,sum(D) 
    where B contains 'Google' 
    and sum(D) > 100 
    group by A,C 
    Order by sum(D) desc label sum(D) 'Total Impressions'")

Above is the formula I tried, but it gives me an error with #VALUE!

Is it an issue with the order of statements?


回答1:


Aggregation functions can be used in select, order by, label, format clauses. They cannot appear in where, group by, pivot, limit, offset, or options clauses.




回答2:


Add a second where should work

query(Sites!A:D,"select A,C,sum(D) 
    where B contains 'Google' 
    and where sum(D) > 100 
    group by A,C 
    order by sum(D) desc label sum(D) 'Total Impressions'")


来源:https://stackoverflow.com/questions/55481292/google-sheets-query-multiple-where-conditions-with-group-by-and-order-by

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!