Re: ORDER BY with exception

From: brian <brian(at)zijn-digital(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: ORDER BY with exception
Date: 2007-06-22 00:46:36
Message-ID: 467B1BEC.2050009@zijn-digital.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Josh Tolley wrote:
> It seems to me you could replace it all with one query, something like
> this:
>
> SELECT discipline, COUNT(1) FROM showcase WHERE EXISTS (SELECT * FROM
> showcase_item WHERE showcase_id = showcase.id LIMIT 1) GROUP BY
> discipline ORDER BY (discipline != 'other'), discipline;
>

discipline is its own table, not a column, so i'd need to throw a join
in there. I have another table, showcase_discipline to relate from
showcases. I did it this way because there are several other tables that
rely on disciplines (one to one and many to one).

And thanks for the ORDER BY tip! I had no idea i could do that. I'll see
if i can work that in.

brian

In response to

Browse pgsql-general by date

  From Date Subject
Next Message brian 2007-06-22 01:08:33 Re: ORDER BY with exception
Previous Message Michael Glaesemann 2007-06-21 23:53:26 Re: ORDER BY with exception