sql菜鸟有问
SELECT DISTINCT后得到如下结果:
2022-08-12 ...... 2022-08-09
求解:怎么写count得到每一天的总量
select date, count(*) ... group by date
@无名啊,感谢大佬,非常好用,想再请教一下,再count一下带条件的 比如count2查询状态state为1的,怎么实现
date count count2 2022-08-12 1000 ? ...... 2022-08-09 2000 ?
@echo醉老仙,3楼的也行
在TRUE代表1,FALSE代表0的数据库上(如MySQL、SQLite),这个也行:
TRUE
1
FALSE
0
MySQL
SQLite
select ..., sum(state = 1) AS state为1个数, sum(state IS NULL) AS state为NULL个数 ...
@无期徒刑,@无名啊, 牛逼,又学到了
select date, count(*) ... group by date