我有这样的桌子
ID | City | Prize
_______________________
1 | Surabaya | Notebook
2 | Surabaya | Notebook
3 | Surabaya |
4 | Bandung | NoteBook
5 | Bandung | PC
6 | Bandung | Handphone
7 | Bandung |
我想按城市、奖品和数量对我的桌子进行分组,如下所示:
ID | City | Prize | QTy
______________________________
1 | Surabaya | Notebook | 2
2 | Bandung | Handphone | 1
3 | Bandung | NoteBook | 1
4 | Bandung | PC | 1
我尝试这个查询但不完美这个我的查询
SELECT City, prize, count( prize ) AS qty
FROM `my_table`
GROUP BY hadiah
谁能帮我解决这个问题?
我非常感谢你的回答。
谢谢
我试过来自 JoeTaras 的查询
SELECT Kota, hadiah, count( hadiah ) AS qty
FROM unik
WHERE hadiah IS NOT NULL
GROUP BY kota, hadiah
结果仍然不正确,Null Value 也是 Count
尝试这个: