按月份查询的SQL语句该怎么写!!
数据库: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表中,该怎么写?
相关推荐
SQL语句,查询当月,当年数据
当月数据 select * from table t where t.create_time >=TRUNC(SYSDATE, 'MM') and t.create_time=trunc(sysdate,'YYYY') and t.create_time=trunc(sysdate,'day')+1 and t.create_time=trunc(next_day(sysdate-8,1)+1) and t.create_time<=trunc(next_day(sysdate-8,1)+7) select trunc(next_day(sysdate - 8, 1) + 1) as 周一, trunc(next_day(sysdate - 8, 1) + 2) as 周二, trunc(next_day(sysdate - 8, 1) + 3) as 周三, trunc(next_day(sysdate - 8, 1) + 4) as 周四, trunc(next_day(sysdate - 8, 1) + 5) as 周五, trunc(next_day(sysdate - 8, 1) + 6) as 周六, trunc(next_day(sysdate - 8, 1) + 7) as 周日 from dual;
SQL Server 查询两个日期之间的所有月份
SQL Server 查询两个日期之间的所有月份示例
数据库sql语句按时间查询全部详解
数据库sql语句按时间查询全部详解 datediff(day,列名,getdate())等函数的使用例子
SQL时间查询语句
各种时间查询语句!年月日~星期,钟点。应有尽有!
SQL查询字段被包含语句
说到SQL的模糊查询,最先想到的,应该就是like关键字。当我们需要查询包含某个特定字段的数据时,往往会使用 ‘%关键字%’ 查询的方式。具体代码示例大家参考下本


