各位老大,小弟刚学sql server不久,有一个查询小弟不知道该怎么写,想求教各位,是这样,我的数据库中每天晚上回插入一条数据 在date列会有一条当前时间纪录在shift列插入day,然后每天早上也会有一条记录,同样在date列插入插入时间,在shift列插入night,我每天早上用一条查询语句只得到昨天晚上的那条记录和今天早上的纪录,这条一句怎么写?
--没到今天晚上
select top 2 * from [table] order by [date] desc
select *
from 表
where
(shift=night and datediff(d,date,getdate())=0)
or
(shift=day and datediff(d,date,getdate())=1)