Google Sheet:如何内爆查询结果的范围

Google Sheet: How to implode a range resulted from a query

我有一个老师sheet和一个Classsheet,每个class都关联一个老师,一个老师可能教多个class.在教师 sheet 中,我想要一个列来显示教师教的 class 内容, class 之间用 ,.

分隔

使用 Query 函数,我已经能够检索 class 特定教师正在教授的内容的单个列范围

QUERY('Class'!A:I,"select B where G='John Smith'")  
//The Class sheet's rightmost column is `I`, column B is `Class_Name` and column G is `Class_Teacher`.

但是,我找不到用 , 来“爆破”这个结果的公式,我能找到的结果是 concatenate

concatenate(QUERY('Class'!A:I,"select B where G='John Smith'"))

这将输出 John Smith 在没有 , 的情况下教授的所有 classes。这可以用公式来完成,还是我必须在应用程序脚本中编写自定义公式?

是的,您可以使用 JOIN() 函数。

=JOIN(",", QUERY('Class'!A:I,"select B where G='John Smith'")))