如何正确排序此查询?

问题描述 投票:-1回答:2

I have this demo sheet

我需要通过列M正确地对单元格I3中的查询进行排序

我有这个公式

=ArrayFormula(IFERROR(QUERY({
IFERROR(QUERY({A3:G},"Select Col1,Col2,Col3,'30',Col5 where Col5 contains 'Days' Label '30' '' ",0),{"","","","",""});
IFERROR(QUERY({A3:G},"Select Col1,Col2,Col3,'60',Col6 where Col6 contains 'Days' Label '60' '' ",0),{"","","","",""});
IFERROR(QUERY({A3:G},"Select Col1,Col2,Col3,'90',Col7 where Col7 contains 'Days' Label '90' '' ",0),{"","","","",""})},
"Select * where Col1 is not null order by Col5",0),""))

我一直在努力工作几个小时没有运气

我根据需要制作了一个标签,预期结果

google-sheets google-sheets-query
2个回答
0
投票
=ARRAYFORMULA(QUERY({IFERROR(QUERY({
IFERROR(QUERY({A3:G},"select Col1,Col2,Col3,'30',Col5 where Col5 contains 'Days' Label '30' '' ",0),{"","","","",""});
IFERROR(QUERY({A3:G},"select Col1,Col2,Col3,'60',Col6 where Col6 contains 'Days' Label '60' '' ",0),{"","","","",""});
IFERROR(QUERY({A3:G},"select Col1,Col2,Col3,'90',Col7 where Col7 contains 'Days' Label '90' '' ",0),{"","","","",""})},
"Select * where Col1 is not null",0),""), 
VALUE(REGEXEXTRACT(IFERROR(QUERY({
IFERROR(QUERY({A3:G},"select Col1,Col2,Col3,'30',Col5 where Col5 contains 'Days' Label '30' '' ",0),{"","","","",""});
IFERROR(QUERY({A3:G},"select Col1,Col2,Col3,'60',Col6 where Col6 contains 'Days' Label '60' '' ",0),{"","","","",""});
IFERROR(QUERY({A3:G},"select Col1,Col2,Col3,'90',Col7 where Col7 contains 'Days' Label '90' '' ",0),{"","","","",""})},
"Select Col5 where Col1 is not null",0),""),"\d+"))}, "select Col1,Col2,Col3,Col4,Col5 order by Col6"))

0


0
投票
  • 字符串按字典顺序排序,即19 Days之前的2 Days为1 <2
  • 从cols5,6和7中的数字中删除Days,您的查询将正常工作。
  • 您可以稍后标记它们:
=ArrayFormula(IFERROR(QUERY({
IFERROR(QUERY({A3:G},"Select Col1,Col2,Col3,'30',Col5 where Col5 contains 'Days' Label '30' '' ",0),{"","","","",""});
IFERROR(QUERY({A3:G},"Select Col1,Col2,Col3,'60',Col6 where Col6 contains 'Days' Label '60' '' ",0),{"","","","",""});
IFERROR(QUERY({A3:G},"Select Col1,Col2,Col3,'90',Col7 where Col7 contains 'Days' Label '90' '' ",0),{"","","","",""})},
"Select Col1,Col2,Col3,Col4,Col5 where Col1 is not null format Col5 '0 Days' order by Col5",0),""))
  • 或者,Days应输入2或3位数:19 Days02 Days
© www.soinside.com 2019 - 2024. All rights reserved.