select top_countries and for each country, select top_cities in that country, in 1 query

From: Dorian Hoxha <dorian(dot)hoxha(at)gmail(dot)com>
To: PostgreSql-general <pgsql-general(at)postgresql(dot)org>
Subject: select top_countries and for each country, select top_cities in that country, in 1 query
Date: 2014-08-18 14:28:23
Message-ID: CANsFX05f5xTNvqvs47j8qathmXB28Xsfq5MbETZfF6krcaWZtA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I have CREATE TABLE t (country text, city text);

I want to get with 1 query,

select count(country),country GROUP BY country ORDER BY count(country) DESC

And for each country, to get the same for cities.

Is it possible ?

Thanks

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Kai Borgolte 2014-08-18 14:51:31 Re: logfile character encoding
Previous Message Holger.Friedrich-Fa-Trivadis 2014-08-18 13:31:32 Re: logfile character encoding