【问题标题】:How to nest more than one QUERY and supply one condition for all the queries如何嵌套多个查询并为所有查询提供一个条件
【发布时间】:2019-07-10 12:20:46
【问题描述】:

我正在尝试嵌套 Google 表格查询,但似乎无法正常工作。我有一个有效的公式,但问题是它将来自不同日期的学生混合在一起。该公式应该返回TODAY()TODAY()+3 之间的所有学生,但应该首先使用TODAY() 学生然后TODAY()+1 等。目前,它首先列出指定日期的所有学生,然后再移动到巢表学生 2 级。

我尝试嵌套查询,然后在最后提供一个我还没有成功的条件。我需要查询在最后共享相同的条件,以便列表按日期排序。或者,如果有办法操纵我当前的公式按日期排序仍然可以。

这是我希望在您的帮助下操纵的工作公式:

={query('Students Level A'!A2:EC, " select EC where A is not null and not 
B contains '-' and EC>=date"""&TEXT(TODAY(),"yyyy-mm-dd")&""" and 
EC<=date"""&TEXT(TODAY()+3,"yyyy-mm-dd")&""" and not B matches '[\d- ] 
{5}' order by EC");
query('Students Level B'!A2:EC, " select EC where A is not null and not B 
contains '-' and EC>=date"""&TEXT(TODAY(),"yyyy-mm-dd")&""" and 
EC<=date"""&TEXT(TODAY()+3,"yyyy-mm-dd")&""" and not B matches '[\d- ] 
{5}' order by EC");
query('Students Level C'!A2:EC, " select EC where A is not null and not B 
contains '-' and EC>=date"""&TEXT(TODAY(),"yyyy-mm-dd")&""" and 
EC<=date"""&TEXT(TODAY()+3,"yyyy-mm-dd")&""" and not B matches '[\d- ] 
{5}' order by EC")}

我正在寻找类似的东西:

={query('Students Level A'!A2:EC);query('Students Level 
B'!A2:EC);query('Students Level C'!A2:EC), "select EC where A is not null 
and not B contains '-' and EC>=date"""&TEXT(TODAY(),"yyyy-mm-dd")&""" and 
EC<=date"""&TEXT(TODAY()+3,"yyyy-mm-dd")&""" and not B matches '[\d- ] 
{5}' order by EC"}

在这个公式中,我首先嵌套查询,然后为之后的所有查询提供一个条件。但是这个公式行不通。

【问题讨论】:

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


    【解决方案1】:

    你需要这样做:

    =QUERY({{'Students Level A'!A2:B, 'Students Level A'!EC2:EC};
            {'Students Level B'!A2:B, 'Students Level B'!EC2:EC};
            {'Students Level C'!A2:B, 'Students Level C'!EC2:EC}}, 
     "select Col3 
      where Col1 is not null 
        and not Col2 contains '-' 
        and Col3 >= date '"&TEXT(TODAY(),   "yyyy-mm-dd")&"' 
        and Col3 <= date '"&TEXT(TODAY()+3, "yyyy-mm-dd")&"'
        and not Col2 matches '[\d- ] {5}' 
      order by Col3", 0)
    

    【讨论】:

      猜你喜欢
      • 2022-11-25
      • 1970-01-01
      • 2016-02-05
      • 2016-04-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多