1
我想獲得整列的累計總和。以下是我的數據樣本。累計總和不工作
DT ETB_DT
Friday 00:00:00.0000000 Friday 04:00:00.0000000
Friday 00:00:00.0000000 Friday 08:00:00.0000000
Friday 00:00:00.0000000 Friday 12:00:00.0000000
Friday 00:00:00.0000000 Friday 16:00:00.0000000
Friday 00:00:00.0000000 Friday 20:00:00.0000000
No_of_records
22
41
86
65
25
我已經使用下面的代碼來獲取應該添加到前一行的累積列。
Select *
,cumulative = sum(No_of_records)
From withoutcumulative4
group by DT,ETB_DT,No_of_records
Order by DT
但是,這給了我以下輸出。
DT ETB_DT
Friday 00:00:00.0000000 Friday 04:00:00.0000000
Friday 00:00:00.0000000 Friday 08:00:00.0000000
Friday 00:00:00.0000000 Friday 12:00:00.0000000
Friday 00:00:00.0000000 Friday 16:00:00.0000000
Friday 00:00:00.0000000 Friday 20:00:00.0000000
No_of_records cumulative
22 22
41 41
86 86
65 65
25 25
以下是我的理想輸出。
DT ETB_DT
Friday 00:00:00.0000000 Friday 04:00:00.0000000
Friday 00:00:00.0000000 Friday 08:00:00.0000000
Friday 00:00:00.0000000 Friday 12:00:00.0000000
Friday 00:00:00.0000000 Friday 16:00:00.0000000
Friday 00:00:00.0000000 Friday 20:00:00.0000000
No_of_records cumulative
22 22
41 63
86 149
65 214
25 239
你們有沒有想法?非常感謝您的幫助。
謝謝你這個工作! – Faheera