我有一个公式,该公式可以汇总来自外部工作表的IMPORTRANGE
数据,然后合并多个查询的输出,效果很好:
={IFERROR(QUERY({
IFERROR(IMPORTRANGE('C1'!C3, "PLACEMENTS!A4:L200"), {"","","","","","","","","","","",""});
IFERROR(IMPORTRANGE('C1'!C4, "PLACEMENTS!A4:L200"), {"","","","","","","","","","","",""});
IFERROR(IMPORTRANGE('C1'!C5, "PLACEMENTS!A4:L200"), {"","","","","","","","","","","",""});
IFERROR(IMPORTRANGE('C1'!C6, "PLACEMENTS!A4:L200"), {"","","","","","","","","","","",""});
IFERROR(IMPORTRANGE('C1'!C7, "PLACEMENTS!A4:L200"), {"","","","","","","","","","","",""});
IFERROR(IMPORTRANGE('C1'!C8, "PLACEMENTS!A4:L200"), {"","","","","","","","","","","",""});
IFERROR(IMPORTRANGE('C1'!C9, "PLACEMENTS!A4:L200"), {"","","","","","","","","","","",""});
IFERROR(IMPORTRANGE('C1'!C10, "PLACEMENTS!A4:L200"), {"","","","","","","","","","","",""});
IFERROR(IMPORTRANGE('C1'!C11, "PLACEMENTS!A4:L200"), {"","","","","","","","","","","",""});
IFERROR(IMPORTRANGE('C1'!C12, "PLACEMENTS!A4:L200"), {"","","","","","","","","","","",""});
IFERROR(IMPORTRANGE('C1'!C13, "PLACEMENTS!A4:L200"), {"","","","","","","","","","","",""});
IFERROR(IMPORTRANGE('C1'!C14, "PLACEMENTS!A4:L200"), {"","","","","","","","","","","",""});
IFERROR(IMPORTRANGE('C1'!C15, "PLACEMENTS!A4:L200"), {"","","","","","","","","","","",""});
IFERROR(IMPORTRANGE('C1'!C16, "PLACEMENTS!A4:L200"), {"","","","","","","","","","","",""});
IFERROR(IMPORTRANGE('C1'!C17, "PLACEMENTS!A4:L200"), {"","","","","","","","","","","",""});
IFERROR(IMPORTRANGE('C1'!C18, "PLACEMENTS!A4:L200"), {"","","","","","","","","","","",""});
IFERROR(IMPORTRANGE('C1'!C19, "PLACEMENTS!A4:L200"), {"","","","","","","","","","","",""});
IFERROR(IMPORTRANGE('C1'!C20, "PLACEMENTS!A4:L200"), {"","","","","","","","","","","",""});
IFERROR(IMPORTRANGE('C1'!C21, "PLACEMENTS!A4:L200"), {"","","","","","","","","","","",""});
IFERROR(IMPORTRANGE('C1'!C22, "PLACEMENTS!A4:L200"), {"","","","","","","","","","","",""});
IFERROR(IMPORTRANGE('C1'!C23, "PLACEMENTS!A4:L200"), {"","","","","","","","","","","",""});
IFERROR(IMPORTRANGE('C1'!C24, "PLACEMENTS!A4:L200"), {"","","","","","","","","","","",""});
IFERROR(IMPORTRANGE('C1'!C25, "PLACEMENTS!A4:L200"), {"","","","","","","","","","","",""});
IFERROR(IMPORTRANGE('C1'!C26, "PLACEMENTS!A4:L200"), {"","","","","","","","","","","",""});
IFERROR(IMPORTRANGE('C1'!C27, "PLACEMENTS!A4:L200"), {"","","","","","","","","","","",""});
IFERROR(IMPORTRANGE('C1'!C28, "PLACEMENTS!A4:L200"), {"","","","","","","","","","","",""});
IFERROR(IMPORTRANGE('C1'!C29, "PLACEMENTS!A4:L200"), {"","","","","","","","","","","",""});
IFERROR(IMPORTRANGE('C1'!C30, "PLACEMENTS!A4:L200"), {"","","","","","","","","","","",""});
IFERROR(IMPORTRANGE('C1'!C31, "PLACEMENTS!A4:L200"), {"","","","","","","","","","","",""})},
"SELECT * WHERE Col8 IS NOT NULL AND Col1='PERSONAL' OR Col1='RESOURCER' OR Col1='NEW' ORDER BY Col12 desc", 0),{"","","","","","","","","","","",""});
IFERROR(QUERY({IFERROR(IMPORTRANGE(MANAGERSHEET, "PLACEMENTS!A4:L200"), {"","","","","","","","","","","",""})},
"SELECT * WHERE Col8 IS NOT NULL AND Col1='PERSONAL' OR Col1='RESOURCER' ORDER BY Col12 desc", 0),{"","","","","","","","","","","",""})}
此查询中的 Col3
作为表示月份的字符串值(“一月”,“二月”,“三月”等)导入。我也在考虑显式地逐一选择列(SELECT Col1, Col2, Col3, etc
),以提高灵活性。
我试图找出查询语句中的 是否有可能转换(或解释)该月的值字符串,以便我可以按月对数字进行排序。即一月= 1,二月= 2,依此类推。
我尝试浏览官方的Google Query Language Reference(0.7版),但标量函数似乎都无法实现我正在尝试执行的操作,或者至少无法以我所使用的任何方式实现尝试过的。谷歌搜索问题也没有找到任何指针,大多数结果都与数字到月份的字符串转换有关,或者暗示了某些Google表格本机函数无法在查询本身中使用。
是否可以在Google表格的Google查询语言中实现而不必求助于单独添加列?
可以在SELECT
过程中将月份名称转换为数字值,还是可以通过ORDER
子句将其解释为数字?