【发布时间】:2018-06-20 08:42:41
【问题描述】:
我在选择查询中使用这些公式,基于 [Date] 字段。学期为 1 月至 6 月,2 月至 7 月至 12 月。 Quarter 是 3 个月的版本(1 月至 3 月等)。
case when Month([Date])>=7 then 2 else 1 end as [Semester],
ceiling((Month([Date])-1)/3)+1 as [Quarter]
这些工作,但我想知道是否有更简单/更优雅的解决方案(尽管我已经检查了 datetime 函数)。
我觉得奇怪的是,带有 ntile() 函数的语言不会有类似的日期。
【问题讨论】:
标签: sql sql-server tsql datetime