1
我有這樣的數據語料庫:SQL查詢,而不是循環
DeviceID Country
id_1 country_1
id_2 country_1
id_3 country_1
id_4 country_2
id_5 country_2
id_6 country_2
,我想造成這樣的:
DistCountries DeviceCount
country_1 3
country_2 3
我用下面的查詢來提取不同的國家列表:
SELECT DISTINCT(Country) as DistCountries FROM devices;
但是,我不知道可以做些什麼來獲得所需的結果。這可以做而不是循環?任何幫助,將不勝感激。
它的工作原理,問候 – dvlper