This shows you the differences between two versions of the page.
— |
kurs:lov_countries [2014/09/10 21:22] (current) |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | <code> | ||
+ | select name, id from ( | ||
+ | SELECT COUNTRIES.COUNTRY_NAME name, | ||
+ | COUNTRIES.COUNTRY_ID id, | ||
+ | count(locations.location_id) | ||
+ | FROM LOCATIONS right join COUNTRIES | ||
+ | on COUNTRIES.COUNTRY_ID = LOCATIONS.COUNTRY_ID | ||
+ | group by COUNTRIES.COUNTRY_NAME, COUNTRIES.COUNTRY_ID | ||
+ | order by count(locations.location_id) desc, country_name asc | ||
+ | ) | ||
+ | </code> |