我建的数据库中 
用户 userid 是int自增长的
生日birthday 字段是datatime类型的 yyyy-mm-dd  怎么样写SQL语句查询从2000-1至2006-1之间 每月有多少个人过生日? group by birthday 就精确到每天了 -_-;大家帮帮我

解决方案 »

  1.   

    select count(birthday) from table where birthday between '2000-1-1' and '2006-1-31' group by month(birthday)
      

  2.   

    select convert(varchar(7),birthday,120) as 月份,count(1) as 生日人数 from table where birthday between '2000-1-1' and '2006-1-31' group by convert(varchar(7),birthday,120)
      

  3.   

    select extract(year from tdate), extract(month from tdate), extract(day from tdate), count from t_t group by extract(year from tdate), extract(month from tdate), extract(day from tdate);