有桌子
A | B | C
BEN | MOSKOW | YES
ANTON | IRKUTSK | NO
VIKTOR | PARIS | YES
BEN | PARIS | YES
ANTON | TORONTO | NO
DON | TORONTO | YES
ANNA | IRKUTSK | YES
BEN | MOSKOW | NO
我使用公式
=UNIQUE(query(A:C; "Select A,B,C where A contains 'BEN' OR A contains 'ANTON' order by A"))
我尝试使用arrayformula
=arrayformula(UNIQUE(query(A:C; "Select A,B,C where A contains 'BEN' OR A contains 'ANTON' order by A")))
但结果列
ANTON | IRKUTSK | NO
ANTON | TORONTO | NO
BEN | MOSKOW | YES
BEN | PARIS | YES
BEN | MOSKOW | NO
我需要结果:
ANTON IRKUTSK NO
ANTON TORONTO NO
BEN MOSCOW YES
BEN PARIS YES
BEN MOSKOW NO
如何在查询中使用concat? Plz帮助
答案 0 :(得分:1)
Google表格concat
中没有query
选项。
JPV建议的解决方法可能适合您: https://stackoverflow.com/a/29799384/5372400
使用公式:
=ARRAYFORMULA(
SUBSTITUTE(
trim(transpose(query(transpose(_your_query_here_),,COLUMNS(_your_query_here_))))," "," → ")
)
将" → "
更改为spase " "
以使结果与空格连接。
有关表格中SQL的更多信息:
https://developers.google.com/chart/interactive/docs/querylanguage
答案 1 :(得分:1)
使用Transpose两次。
=transpose(query(transpose(_you query_);;COLUMNS(_you query_)))
我的问题中的一个例子:
=transpose(query(transpose(UNIQUE(query(A:C; "select * where A contains 'BEN' OR A contains 'ANTON' order by A")));;COLUMNS(UNIQUE(query(A:C; "select * where A contains 'BEN' OR A contains 'ANTON' order by A")))))
结果:
ANTON IRKUTSK NO
ANTON TORONTO NO
BEN MOSCOW YES
BEN PARIS YES
BEN MOSKOW NO