THENUMBER NUMBER SYSMODTIME TYPE
ACTIM2816332 IM0540202 2014-11-18 09:17:53.000 Closed
ACTIM2806050 IM0540202 2014-11-13 15:11:29.000 Update
ACTIM2806051 IM0540202 2014-11-13 15:11:29.000 External Vendor Assignment
ACTIM2806049 IM0540202 2014-11-13 15:11:29.000 Status Change
ACTIM2806046 IM0540202 2014-11-13 15:10:34.000 Assignment
ACTIM2804167 IM0540202 2014-11-13 09:31:12.000 Status Change
ACTIM2804166 IM0540202 2014-11-13 09:31:12.000 Assignment
ACTIM2802130 IM0540202 2014-11-12 17:09:57.000 Open
你能帮我创建一个选择来计算从打开到关闭的类型变化之间的时差吗?
我需要成为不同NUMBER的通用。
答案 0 :(得分:1)
<强>分钟强>
SELECT NUMBER, MAX([SYSMODTIME]) AS Closed, MIN([SYSMODTIME]) AS Open,
(DATEDIFF (mi, MAX([LoginDateTime]), MIN([SYSMODTIME]))) AS [datediff]
FROM table
GROUP BY NUMBER
<强>小时强>
SELECT NUMBER, MAX([SYSMODTIME]) AS Closed, MIN([SYSMODTIME]) AS Open,
(DATEDIFF (hh, MAX([LoginDateTime]), MIN([SYSMODTIME]))) AS [datediff]
FROM table
GROUP BY NUMBER