當前位置:首頁 » 編程語言 » sql累計求和

sql累計求和

發布時間: 2023-08-03 15:05:53

sql欄位累加求和的問題

SELECT ID,STRING1,STRING2 from table UNION
select ID=0,string1=string1+'小計',countresult=count(1),sum1=sum(string2) from talbe group by string1 union
select ID=0,string1='總計',countresult=count(1),sum1=sum(string2) from table order by string1,id
結果為包括了小計和總計,和明細,並按順序排列

⑵ sql分組求和

1、使用having對分組結果進行過濾,一般情況下having是放在group by的後面。

熱點內容
2016空間加密怎麼進 發布:2025-02-07 01:41:30 瀏覽:382
網路數據伺服器是什麼 發布:2025-02-07 01:23:42 瀏覽:473
多伺服器ip白名單 發布:2025-02-07 01:23:41 瀏覽:372
優酷上傳視頻的格式 發布:2025-02-07 01:18:51 瀏覽:880
租虛擬伺服器有什麼用 發布:2025-02-07 01:17:55 瀏覽:4
視頻腳本策劃 發布:2025-02-07 01:15:37 瀏覽:566
外文免費資料庫 發布:2025-02-07 01:12:26 瀏覽:194
第一滴血ftp 發布:2025-02-07 01:12:24 瀏覽:424
仿草料源碼 發布:2025-02-07 01:08:31 瀏覽:532
python多線程map 發布:2025-02-07 01:04:37 瀏覽:463