我正在尝试从符合两个条件的工作表中查询数据。但是,当在符合我的条件的数据中有多于一行时,查询仅返回第一个结果。如何确保它返回所有符合条件的行?
我尝试更改单引号和双引号,大写字母,更改数据格式,但无济于事。
查询:
query(Raw!A1:J29041, "select B,C,D,E, sum(F) where B='"&sheet1!A2&"' and E='good source' and not C='2016' GROUP BY B,C,D,E")
数据示例:
Client Year Month Source Count
Client a 2019 July other source 1
Client a 2019 July good source 2
Client a 2019 July bad source 22
Client a 2019 July good source 63
Client a 2019 July another source 1
Client a 2019 July another source 8
此数据的所需输出:
Client Year Month Source sum
Client a 2019 July other source 65
答案 0 :(得分:1)
数字不应该用单引号引起来
尝试:
=QUERY(Raw!A1:J29041,
"select B,C,D,E,sum(F)
where B="&sheet1!A2&"
and E='good source'
and not C='2016'
group by B,C,D,E", 1)
或:
=QUERY(Raw!A1:J29041,
"select B,C,D,E,sum(F)
where B="&sheet1!A2&"
and E='good source'
and not C=2016
group by B,C,D,E", 1)