我的SQL查詢組中的多個字段數據作爲一個字段
select status,count(id) from table group by status;
回報以下數據
Resolved- 4
Closed - 12
Verified - 3
New* - 23
Unconfirmed* - 4
Needmoreinfo* - 5.
我希望MySQL返回什麼是
Resolved- 4
Closed - 12
Verified - 3
Found* - 32
即新的,未確認,Needmoreinfo應計爲'發現'
提供一些示例表數據並準確解釋問題。 – Wanderer
select CASE WHEN status NOT IN('Resolved','Closed','Verified')THEN'FOUND'ELSE status END as derived_status,count(id)from table group by CASE WHEN status NOT IN('Resolved','Closed ','已驗證')然後'找到'ELSE狀態結束; –