2014-11-01 67 views
1

這是我當前的查詢:與COUNT獲取行的名稱在SQL

SELECT COUNT(`location`) AS 'amount' FROM offers GROUP BY location; 

這將返回:

enter image description here

不過,我希望能夠歸因每一個數目價值。例如,它會輸出:

enter image description hereenter image description here

基本上,基

SELECT COUNT(`location`) AS 'amount' FROM offers GROUP BY location; 

SELECT location FROM offers GROUP BY location; 

成一個查詢

+0

'選擇位置,計數(位置)量報價按位置' – Jhecht 2014-11-01 23:04:28

回答

1

嘗試:

SELECT location, COUNT(location) AS amount 
FROM offers 
GROUP BY location 
0

使用此:

select location,count(*) As amount from offers group by location;