sql统计查询问题 麻烦死了 帮个忙吧
数据库有个字段fxsj(日期/时间),
通过sql查询某年度某月份的记录集的个数!例如:2011年12月中记录集的个数
sql="select count(id) as num where ....)"咋写?
------解决方案--------------------select count(id) as num from 表 where month(日期)=12
select count(*) as c from(select * from ss inner join gq where ss.gqmc=qq.gqmc) as t1 inner join cj where t1.id=cj.id group by cj.id
------解决方案--------------------select count(*) from table_name where to_char(fxsj,'yyyy-mm')='2011-12';
------解决方案--------------------Select count(c.*)
From cj As a,gq As b,ss As c
Where convert(varchar,datepart(mm,c.fxsj)) = '要查询的月份' ' And c.gqmc = b.gqmc And b.cjid = a.id
试试