select county, count(county) as total_entry from house
group by county;
我明白了
county | total_entry
'county1'| '1'
'county2'| '11'
'county3'| '2'
现在我想得到以下结果:
county | ad_type | total_entries
'county1'| SALE | '1'
'county2'| SALE | '4'
'county2'| RENT | '5'
'county2'| NEWHOUSING | '2'
'county3'| RENT | '2'
我怎样才能做到这一点?(ad_type是内部表中的字段)。
最佳答案
试试这样的方法:(我假设你的和数是关闭的,因为你也想按广告类型分组)
SELECT county, COUNT(county) AS counties, ad_type FROM house
GROUP BY county, ad_type