日期:2014-05-17 浏览次数:20481 次
select top 10 * from tb where DATEPART(weekday,LoginTime) in(6,7) order by LoginTime desc
------解决方案--------------------
select distinct b.* from tb a cross apply (select top 10 * from tb where LoginTime=a.LoginTime and DATEPART(weekday,LoginTime) in(6,7) order by LoginTime desc)b
------解决方案--------------------
你有什么辅助信息可以查到哪天对应的是星期几吗?如果没有,可以使用以下方法获取某天是星期几:
select DATENAME(WEEKDAY,@Date) AS '本日是周几' select DATEPART(WEEKDAY,@Date) AS '本日是周几'--返回值 1-星期日,2-星期一,3-星期二......7-星期六
------解决方案--------------------
select top 10 loginIP,loginTime from 表 where datepart(weekday,loginTime)=6 or datepart(weekday,loginTime)=7