Re: query on query

Поиск
Список
Период
Сортировка
От Jayadevan M
Тема Re: query on query
Дата
Msg-id 3411BBAFF5A2244FA405CC91D9473A602369B11F@PBOX2.ibsplc.com
обсуждение исходный текст
Ответ на Re: query on query  (Luca Ferrari <fluca1978@infinito.it>)
Список pgsql-general
>
>>
>> So each student may get counted many times, someone with 99 will be
>> counted
>> 10 times. Possible to do this with a fat query? The table will have
>> many thousands of records.
>>
>
>
>Not sure I got the point, but I guess this is a good candidate for a CTE:
>
>WITH RECURSIVE t(n) AS (
>    VALUES (10)
>  UNION ALL
>    SELECT n+10 FROM t WHERE n < 50
>)
>select count(*), t.n from m, t where mark > t.n group by t.n;

I meant 'fast', not 'fat. Sorry for the typo.

You got it right. The query gets the data exactly as I wanted it. Thanks a lot.

Regards,
Jayadevan


DISCLAIMER: "The information in this e-mail and any attachment is intended only for the person to whom it is addressed
andmay contain confidential and/or privileged material. If you have received this e-mail in error, kindly contact the
senderand destroy all copies of the original communication. IBS makes no warranty, express or implied, nor guarantees
theaccuracy, adequacy or completeness of the information contained in this email or any attachment and is not liable
forany errors, defects, omissions, viruses or for resultant loss or damage, if any, direct or indirect." 


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

Предыдущее
От: Luca Ferrari
Дата:
Сообщение: Re: query on query
Следующее
От: giozh
Дата:
Сообщение: Re: unable to call a function