sql 语句 count 0值显示问题
有一张表的数据如图所示,表名为AA_company,有如下sql语句selecttype,COUNT(type)astotalfromAA_companywhererem...
有一张表的数据如图所示,表名为AA_company,有如下sql语句
select type, COUNT(type) as total from AA_company where remain>5 group by type
结果如下:
我想把COUNT(type)为0的type也给显示出来,也就是“互联网”、“文化”、”财经“也在结果中显示,并且total值为0.怎么解决?
select type, ISNULL(COUNT(type),0) as total from AA_company where remain>5 group by type
加了ISNULL也不行。
谢谢各位了。 展开
select type, COUNT(type) as total from AA_company where remain>5 group by type
结果如下:
我想把COUNT(type)为0的type也给显示出来,也就是“互联网”、“文化”、”财经“也在结果中显示,并且total值为0.怎么解决?
select type, ISNULL(COUNT(type),0) as total from AA_company where remain>5 group by type
加了ISNULL也不行。
谢谢各位了。 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询