From: | Jayadevan M <jayadevan(dot)maymala(at)ibsplc(dot)com> |
---|---|
To: | 'Luca Ferrari' <fluca1978(at)infinito(dot)it> |
Cc: | "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: query on query |
Date: | 2013-07-05 07:02:55 |
Message-ID: | 3411BBAFF5A2244FA405CC91D9473A602369B11F@PBOX2.ibsplc.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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 and may contain confidential and/or privileged material. If you have received this e-mail in error, kindly contact the sender and destroy all copies of the original communication. IBS makes no warranty, express or implied, nor guarantees the accuracy, adequacy or completeness of the information contained in this email or any attachment and is not liable for any errors, defects, omissions, viruses or for resultant loss or damage, if any, direct or indirect."
From | Date | Subject | |
---|---|---|---|
Next Message | giozh | 2013-07-05 07:29:07 | Re: unable to call a function |
Previous Message | Luca Ferrari | 2013-07-05 06:35:22 | Re: query on query |