愿天天向上,愿学以致用,愿掌握生活
SQL把日期转换为季度来作查询
上一篇 /
下一篇 2007-10-03 15:36:38 / 天气: 晴朗
/ 心情: 一般
/ 个人分类:数据库
SQL 里面没有季度函数
Select Season = Case when month(日期) in (1,2,3) then '一季度'
when month(日期) in (4,5,6) then '二季度'
when month(日期) in (7,8,9) then '三季度'
when month(日期) in (10,11,12) then '四季度' end ,
count(*)
from tablename
group by Case when month(日期) in (1,2,3) then '一季度'
when month(日期) in (4,5,6) then '二季度'
when month(日期) in (7,8,9) then '三季度'
when month(日期) in (10,11,12) then '四季度' end
查询结果为 按季度分组后的各季度记录数量
相关阅读:
- 教你轻松掌握如何为示例数据库启用Java (51testing, 2007-9-18)
- 教你轻松掌握SQL Server的数据同步技术 (51testing, 2007-9-19)
- 开源数据库:MySQL企业套装即将发布 (51testing, 2007-9-20)
- Oracle压力测试之orabm (51testing, 2007-9-20)
- 用orabm测试oracle服务器的TPS值 (51testing, 2007-9-21)
- Oracle与DB2数据类型分类对应说明 (51testing, 2007-9-24)
- ORACLE UPDATE 语句语法与性能分析的一点看法(转载) (by1945, 2007-9-24)
- SQL Server数据库复制的简化 (51testing, 2007-9-25)
- TestComplete对数据库的支持 (51testing, 2007-9-26)
- SQL通配符 (spinach_xu, 2007-10-03)
收藏
举报
TAG:
季度
数据库