如果I型Sql數據組合?
SELECT petid1, COUNT(*) AS total FROM cdc_padchat WHERE petid1 !=0 GROUP BY petid1
ORDER BY total DESC
它將輸出以下數據
如果I型
SELECT petid2, COUNT(*) AS total FROM cdc_padchat WHERE petid2 !=0 GROUP BY petid2
ORDER BY total DESC
它將輸出以下數據
我該如何分組同樣的結果呢? 例如petid1 = 1218總計結果+ petid2 = 1218總計結果= 20 + 9 = 29
謝謝,我已經解決了這個問題! –