代码之家  ›  专栏  ›  技术社区  ›  Bentaiba Miled Basma Ned Batchelder

强制sqlite select查询不返回任何内容而不是null

  •  0
  • Bentaiba Miled Basma Ned Batchelder  · 技术社区  · 7 年前

    我有一个类似的问题:

    select distinct 'density' as feature, density as value, 
           count(density) as frequency 
    from cases
    where density in not null;
    

    我们将其称为查询A,下一个查询是查询B。

    在查询B的情况下:

    select distinct density as value, count(density) as frequency 
    from cases
    where density in not null;
    

    ('density', null, null)
    

    但我希望查询A不返回任何内容。问题是,如何重构查询A以强制它在解释的情况下不返回任何内容?

    1 回复  |  直到 7 年前
        1
  •  1
  •   Gordon Linoff    7 年前

    尝试这样做:

    select 'density' as feature, density as value, 
           count(density) as frequency 
    from cases
    where density is not null
    group by density;
    

    where ,然后 group by 将不返回任何行。