当前位置: 代码迷 >> Sql Server >> Sql 难题 小弟我是初学者哪位高手来帮小弟我
  详细解决方案

Sql 难题 小弟我是初学者哪位高手来帮小弟我

热度:270   发布时间:2016-04-27 13:56:44.0
Sql 难题 我是菜鸟谁来帮我
我想查询一个时间段内的日期的内容,好比说2010年1月20日~~~~2012年3月1日 每日的5号的数据

还要判断如果五号是周六或者周日的话, 按周五的数据 得出来这个时间段的内容 该怎么做呀




------解决方案--------------------
SQL code
set datefirst 1select *from tbwhere date between '2010-01-20' and '2012-03-01'    and day(date) = (case when datepart(weekday,date) in (6,7) and day(date) = 5                          then 10-datepart(weekday,date) else 5 end)-- try
  相关解决方案