-- 表a
-- 字段 a_status, a_date
-- 数据 0 2013-01-01
-- 数据 1 2013-01-02
-- 数据 0 2013-02-01
-- 数据 1 2013-02-02
-- 数据 1 2013-02-03
-- 求sql:按年和月分组,找出a_status为0的数据条数和a_status为1的数据条数,
-- 要求查出的数据如下:
-- count0 count1 a_date
-- 1 1 2013-01
-- 1 2 2013-02下sql只能查出总的,未区分a_status,可参考。
select count(*) ,a_date
from a
group by year(a_date),
month(a_date);先谢谢了。SQL行业数据select
-- 字段 a_status, a_date
-- 数据 0 2013-01-01
-- 数据 1 2013-01-02
-- 数据 0 2013-02-01
-- 数据 1 2013-02-02
-- 数据 1 2013-02-03
-- 求sql:按年和月分组,找出a_status为0的数据条数和a_status为1的数据条数,
-- 要求查出的数据如下:
-- count0 count1 a_date
-- 1 1 2013-01
-- 1 2 2013-02下sql只能查出总的,未区分a_status,可参考。
select count(*) ,a_date
from a
group by year(a_date),
month(a_date);先谢谢了。SQL行业数据select
解决方案 »
- mysql 多表随机查询语句的写法【help】
- [100分]在windows2003上制作的jsp网站,过两天数据库就死掉了,系统必须重起,mysql才可用!!
- mysql union 与union all 使用
- mysql数据恢复
- mysql4.2以上版本???
- MySQL数据库问题
- STDDEV是不是计算标准差,好象和程序计算所的有偏差
- 我的php程序用postgres7.2.1,后来放到postgres7.3的主机上,出现错误! 急
- mysql 与amoeba 连接的问题。
- sqlserver中的varchar字段插入到mysql的text中不成功
- 求一条sql语句
- 安装mysql,安装不了!
select substring(a_date,1,7)
,count(case when a_status=0 then 1 end)
,count(case when a_status=1 then 1 end)
from tb
group by substring(a_date,1,7)
谢谢啦。大哥的sql炉火纯青呀,小弟拜倒。等下忙完了就结贴。