2016-01-20 25 views
0

嗨我想查詢我的表中不同的地方。如何使用獨特的黑斑羚

這是我的查詢。

select distinct city,locality, avg_sqft from real_estate.re_search where city = 'bangalore' AND locality != 'jayanagar'; 

結果

+-----------+--------------+----------+ 
| city  | locality  | avg_sqft | 
+-----------+--------------+----------+ 
| bangalore | bannerghatta | 13500 | 
| bangalore | kormangala | 18000 | 
| bangalore | kodipur  | 7000  | 
| bangalore | kormangala | 16000 | 
| bangalore | horamavu  | 9000  | 
| bangalore | bellandur | 15500 | 
| bangalore | kodipur  | 9000  | 
| bangalore | madivala  | 12000 | 
| bangalore | varthur  | 12000 | 
| bangalore | kormangala | 13500 | 
| bangalore | bellandur | 13000 | 
| bangalore | kodipur  | 11500 | 
| bangalore | kormangala | 14000 | 

問題是我需要顯示在result.any幫助不同地區將不勝感激。

+0

我不知道商業用途但是相同的位置在不同的行中具有不同的平方英尺值。如果可以對這些值進行求和,您可以通過下面的方法實現不同的地點。從城市,地點選擇城市,地點,總和(avg_sqft)from real_estate.re_search where city ='bangalore'AND locality!='jayanagar'group; – BigData

回答

1

你應該能夠得到您的表,所在城市班加羅爾是通過使用COUNTGROUP BY運營商所在地列中不同成員的名單:

SELECT city 
     ,locality 
     ,COUNT(locality) 
FROM database.table 
WHERE city = 'Bangalore' 
GROUP BY city 
     ,locality; 
相關問題