select (case when col >= convert(date, getdate()) then 'Today'
when col >= dateadd(day, -1, convert(date, getdate())) then 'Yesterday'
when col >= dateadd(day, -6, convert(date, getdate())) then datename(weekday, col)
when col >= dateadd(day, -13, convert(date, getdate())) then 'Last Week'
when col >= dateadd(day, -20, convert(date, getdate())) then 'Two Weeks Ago'
when col >= dateadd(day, -27, convert(date, getdate())) then 'Thre Weeks Ago'
else 'Older'
end)
1条答案
按热度按时间mwkjh3gx1#
如果要定义时间段,请使用
case
. 你并没有真正定义确切的定义,但是像这样:这是一把小提琴。