0
SQL Server,如何從日程表中找到時間片,就像我需要輸出第一列的結束時間和下一列的開始時間一樣?SQL Server在開始時間和結束時間之間查找時間片
select
s, e,
Max(cid)as c_id,
ROW_NUMBER()OVER(order by CAST(s as datetime)) as row_id
from classroom
where Room like '3310' and Days like '%T%'
group by s,e
order by CAST(s as datetime)
例如:
s e c_id row_id
------- ------- ------- ------
9:30 10:45 235 1
11:00 12:15 236 2
12:30 13:45 238 3
14:00 15:15 1415 4
15:30 16:45 273 5
17:00 18:15 270 6
我需要輸出
10:45-11:00
12:15-12:30
13:45-14:00
感謝