有人知道Google Spreadsheets中的查询功能是否支持使用Case语句吗?如果没有,是否有另一种方法可以帮助产生所需的输出,如Oracle中使用的If语句或Decode?
例如,我正在查询D列的日期:
=QUERY(FPA!B:Q,"SELECT Sum( Case Month(D) when 1 then 1 else 0 end) as ‘JAN’,
Sum( Case Month(D) when 2 then 1 else 0 end) as ‘FEB’,
Sum( Case Month(D) when 3 then 1 else 0 end) as ‘MAR’",1)
电子表格:
Employee | Start Dt | Location
-------------------------------------
John Smith | 03-Mar-2015 | New York
Mary Jane | 27-Jan-2015 | Los Angeles
Kim Wagner | 13-Feb-2015 | Chicago
输出:
Location | JAN | FEB | MAR
-----------------------------
New York | | | 1
Chicago | | 1 |
Los Angeles | 1 | |
答案 0 :(得分:0)
要模仿该结果,您可能需要尝试类似
的内容=ArrayFormula(query({UPPER(text(B2:B, "mmm")),B2:C}, "select Col3, count(Col2) where Col2 is not null group by Col3 pivot Col1"))