按月份查询的SQL语句该怎么写!!
操作系统:WIN2000
数据库:SQLSERVER2000
要求按年和月统计数据,例如2004/2,即2004年2月份的数据统计。由于月份有28、29、30、31日期不等,不能用介于1日到31日之间查询,请高手想个办法。
Select A.department,count(A.number) as cntuser,sum(A.account) as totalfee,B.unitname from sales A join department B on A.department=B.id group by A.dsldepart,B.unitname
基本语句就这样,要加个where,A表日期字段名为saledate,格式年/月/日.如果要查给定条件“2004/2”的数据从A表中,该怎么写?