select...count() ╰半夏微凉° 2021-11-17 03:54 309阅读 0赞 declare @t table( c varchar(10)); insert @t select \* from ( select 'A' as c union all select 'B' union all select 'B' union all select null union all select null ) t; select count(\*) from @t; select count(c) from @t; select count(distinct c) from @t; select distinct c from @t; 测一下上面最后四条语句的执行结果: ![ContractedBlock.gif][] ![ExpandedBlockStart.gif][] Code ![None.gif][]\--\--------- ![None.gif][]**5** ![None.gif][] ![None.gif][] ![None.gif][]\--\--------- ![None.gif][]**3** ![None.gif][]Warning: Null value is eliminated by an aggregate or other SET operation. ![None.gif][] ![None.gif][] ![None.gif][]\--\--------- ![None.gif][]**2** ![None.gif][]Warning: Null value is eliminated by an aggregate or other SET operation. ![None.gif][] ![None.gif][] ![None.gif][]c ![None.gif][]\--\-------- ![None.gif][]NULL ![None.gif][]A ![None.gif][]B ![None.gif][] ![None.gif][] 转载于:https://www.cnblogs.com/aspsmile/archive/2009/03/04/1402825.html [ContractedBlock.gif]: https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif [ExpandedBlockStart.gif]: /images/20211116/d94c272e092a4e76a292b44203bc64b3.png [None.gif]: /images/20211116/408ed8f526d143d096fcd624d4d24122.png
相关 MyBatis-Plus 之selectMaps、selectObjs、selectCount、selectOne 推荐:[MyBatis Plus汇总][MyBatis Plus] MyBatis-Plus 之selectMaps、selectObjs、selectCount、sele 我会带着你远行/ 2022年12月13日 09:58/ 0 赞/ 144 阅读
相关 SelectCount不支持Distinct `如图所示,selectcount只是count(1)`,想统计count(distinct)只能另寻他法了 ![不支持Distinct语句][Distinct] [D Dear 丶/ 2021年09月25日 13:08/ 0 赞/ 688 阅读
还没有评论,来说两句吧...