【问题标题】:Is it possible to implement multi-stage SORT using QUERY?是否可以使用 QUERY 实现多阶段 SORT?
【发布时间】:2020-02-15 15:24:29
【问题描述】:

https://docs.google.com/spreadsheets/d/1XoxAY8MEgrGrpG1yJ2VthHDOGr6u2pBZC1YotpDfslE/edit?usp=sharing

标签Deck Trends单元格A3包含QUERY命令,您可以在其中查看当前排序顺序。

我想要达到的目标如下:

Col E 等于 4 的任何行,我希望 secondary 排序基于 Col F

我希望 secondary 排序基于Col D 的所有其他行(目前已设置)。

甚至可以在一个QUERY 中拥有多个排序规则吗?

【问题讨论】:

  • E cloumn 中的值 4 是可能的最高值吗?

标签: arrays google-sheets google-sheets-formula google-sheets-query google-query-language


【解决方案1】:

尝试:

=QUERY({QUERY({
 'Combined Opp Meta'!A2:G11; 'Combined Opp Meta'!A14:G23; 'Combined Opp Meta'!A26:G35},
 "where Col5 = 4
  order by Col5 desc,Col6 desc", 0);
 QUERY({
 'Combined Opp Meta'!A2:G11; 'Combined Opp Meta'!A14:G23; 'Combined Opp Meta'!A26:G35},
 "where Col5 <> 4
  order by Col5 desc,Col4 desc", 0)},
 "limit 12", 0)

数组文字修复:

=QUERY({IFERROR(QUERY({
 'Combined Opp Meta'!A2:G11; 'Combined Opp Meta'!A14:G23; 'Combined Opp Meta'!A26:G35},
 "where Col5 = 4
  order by Col5 desc,Col6 desc", 0), {"","","","","","",""});
 IFERROR(QUERY({
 'Combined Opp Meta'!A2:G11; 'Combined Opp Meta'!A14:G23; 'Combined Opp Meta'!A26:G35},
 "where Col5 <> 4
  order by Col5 desc,Col4 desc", 0), {"","","","","","",""})},
 "where Col1 is not null limit 12", 0)

【讨论】:

  • 绝对完美!非常感谢,这很有帮助,我可以将其应用于电子表格的其他方面。
  • 哦,我刚刚发现了一个问题 - 当 Col5 = 4 中没有值时,它会引发 ARRAY_LITERAL 错误!
  • 哦,这比我想出的要好得多。谢谢大家!
猜你喜欢
  • 2019-03-09
  • 2012-07-08
  • 1970-01-01
  • 2022-07-16
  • 2020-09-08
  • 1970-01-01
  • 2020-03-22
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多