Search Postgresql Archives

Re: ORDER BY with exception

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux