圖:1-1
這裏有兩列數據
1.分類統計
select test_id,user_id,sum(test_id) over(partition by user_id) from 表名
EG:partition是劃分的意思,在這裏上面的SQL語句我們可以理解成遞增相加TEST_ID(sum函數)通過USER_ID,說白了就是分組相加
結果爲:
圖1-2
2.如果不需要已某個欄位的值分割
還是以圖1-1作爲講解
如果我們不需要以某個值爲劃分,SQL語句可寫成:
select test_id,user_id,sum(test_id) over(partition by null) from 表名
結果爲: