有如下表:table
-----------------------------------
Filed0                  Filed1
-----------------------------------
a                          1
a                          2
a                          2
b                          2
b                          3
b                          3
------------------------------------
执行:select Filed0,count(*) from table where Filed1>2 group by Filed0
得到结果:
------------------------------------
b                          2
------------------------------------
执行:(select Filed0,count(*) from table where Filed1>2 group by Filed0) union (select Filed0,0 from table where Filed0 not in (select Filed0 from table where Filed1>2) group by Filed0) order by Filed0
得到结果:
------------------------------------
a                          0
b                          2
------------------------------------
 

相关文章:

  • 2021-07-17
  • 2022-12-23
  • 2022-12-23
  • 2021-07-24
  • 2021-11-17
  • 2021-03-30
  • 2021-10-02
猜你喜欢
  • 2021-10-24
  • 2021-06-02
  • 2021-05-20
  • 2022-12-23
  • 2021-08-05
  • 2021-12-16
相关资源
相似解决方案