2014-09-02 161 views
-1

select * from test;簡單的sql查詢不同/數

+--------+------+ 
| name | age | 
+--------+------+ 
| asif | 20 | 
| mithun | 20 | 
| vinod | 21 | 
+--------+------+ 

我想O/P如下

age count 
20 2 
21 1 

回答

3

你能試試嗎?

SELECT age,count(age) as count from test GROUP BY age 
+0

它應該是''''選擇年齡,從測試組數(年齡)作爲計數BY age'''';) – 2014-09-02 09:23:49

+1

是啊,我忘了補充。但我編輯:) – 2014-09-02 09:24:17

+0

謝謝@punithasubramaniv – 2014-09-02 09:27:34