Re: sub-limiting a query

Поиск
Список
Период
Сортировка
От Louis-David Mitterrand
Тема Re: sub-limiting a query
Дата
Msg-id 20070217183959.GA29756@apartia.fr
обсуждение исходный текст
Ответ на Re: sub-limiting a query  ("M.P.Dankoor" <m.p.dankoor@gmail.com>)
Список pgsql-sql
On Sat, Feb 17, 2007 at 07:21:40PM +0100, M.P.Dankoor wrote:
> Louis-David Mitterrand wrote:
> >  
> I thought of another solution, actually it's of those top n query tricks 
> that I picked up somewhere, can't remember
> where.
> Assuming that your table is called shows, the following query should 
> give you the results you want (hope so)
> 
> SELECT *
> FROM shows a
> WHERE 3 > (SELECT COUNT(*)
>           FROM shows b
>           WHERE b.created_on >= a.created_on
>           and a.show_type = b.show_type)

This is stunning and it works!

I can barely understand the query: it's so terse it hurts :)

/me goes back studying it


Thanks a lot!


В списке pgsql-sql по дате отправления:

Предыдущее
От: "M.P.Dankoor"
Дата:
Сообщение: Re: sub-limiting a query
Следующее
От: Bruce Momjian
Дата:
Сообщение: Re: Odd PL/PgSQL Error -- relation "X" does not exist when using index expression