可以用case when 吧!哈哈 select case d.weekday1 when '星期一' then '是' when '星期日' then '是' else '否' end 是否再同一周 from (SELECT 1 as Row, datename(weekday, '2007-1-1') weekday1 union SELECT 2 as row, datename(weekday, '2007-1-4') union SELECT 3 as row ,datename(weekday, '2007-1-6') ) d where row =1
select datepart(week,'2007/01/01') from tablename where datepart(week,'2007/01/01')=datepart(week,'2007/01/06') and datepart(week,'2007/01/06')=(week,'2007/01/01') 當是同一周時就會顯示出為一年中的第幾周,但不是同一周時就沒有顯示。
select case count(a) when 1 then '是同一周' else '不是同一周' end 是否同一周 from ( select datename(week,'2007-1-1') a union select datename(week,'2007-1-4') union select datename(week,'2007-1-5')) d