鉴于以下样本查询,其中Col A为Dates,而Col B为Numbers:
=QUERY(Sheet1!A:C, "SELECT A, SUM(B) WHERE (C = 'Www' OR C = 'ccC') GROUP BY A",1)
即使SUM(B)为= NULL,并且NULL显示为0(如ISNULL),如何显示下一个GROUP BY A的结果?在T-SQL中有一种方法可以做到这一点,但它不适用于谷歌。有人知道吗?
期望的结果:
<table border="1" style="width:20%">
<tr>
<td>1/1/02</td>
<td>5</td>
</tr>
<tr>
<td>1/2/02</td>
<td>0</td>
</tr>
<tr>
<td>1/3/02</td>
<td>5</td>
</tr>
<tr>
<td>1/4/02</td>
<td>10</td>
</tr>
<tr>
<td>1/5/02</td>
<td>0</td>
</tr>
</table>
&#13;
答案 0 :(得分:0)
=QUERY({Sheet1!A:A,ARRAYFORMULA(IF((Sheet1!C:C="Www")+(Sheet1!C:C="ccC"),Sheet1!B:B,0)),Sheet1!C:C}, "SELECT Col1, SUM(Col2) WHERE Col1 is not null GROUP BY Col1",1)