发布网友 发布时间:2022-04-24 12:02
共1个回答
热心网友 时间:2022-04-10 00:49
SELECT uptime, CASE WHEN datepart(hour,uptime) IN (0,1) THEN 1
WHEN datepart(hour,uptime) IN (2,3) THEN 2
WHEN datepart(hour,uptime) IN (4,5) THEN 3
WHEN datepart(hour,uptime) IN (6,7) THEN 4
WHEN datepart(hour,uptime) IN (8,9) THEN 5
WHEN datepart(hour,uptime) IN (10,11) THEN 6
WHEN datepart(hour,uptime) IN (12,13) THEN 7
WHEN datepart(hour,uptime) IN (14,15) THEN 8
WHEN datepart(hour,uptime) IN (16,17) THEN 9
WHEN datepart(hour,uptime) IN (18,19) THEN 10
WHEN datepart(hour,uptime) IN (20,21) THEN 11
WHEN datepart(hour,uptime) IN (22,23) THEN 12
ELSE 0 END AS sq
FROM bak_dircost0901
-------------------------------
uptime sq
2014/8/19 9:20:59 5
2014/8/22 20:31:20 11
2014/8/22 20:33:08 11
2014/8/26 13:48:01 7
2014/8/27 16:10:45 9