SQL,group by分組后分別計算組內不同值的數量


select name as 姓名,
sum( case when cargo='筆' then 1 else 0 end ) as 筆,
sum( case when cargo='橡皮' then 1 else 0 end ) as 橡皮
from shopping group by name;


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM