示例:查询id大于10和id等于3的统计。
一般写法
select count(case when id>10 then id end),count(case when id=3 then id end ) from test;
非主流写法:
select count(id>10 or null),count(id=3 or null) from test;
去重统计:
select count(distinct username) from user;
示例:查询id大于10和id等于3的统计。
一般写法
select count(case when id>10 then id end),count(case when id=3 then id end ) from test;
非主流写法:
select count(id>10 or null),count(id=3 or null) from test;
去重统计:
select count(distinct username) from user;