Re: query on query - Mailing list pgsql-general

From Jayadevan M
Subject Re: query on query
Date
Msg-id 3411BBAFF5A2244FA405CC91D9473A602369B11F@PBOX2.ibsplc.com
Whole thread Raw
In response to Re: query on query  (Luca Ferrari <fluca1978@infinito.it>)
List 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 by date:

Previous
From: Luca Ferrari
Date:
Subject: Re: query on query
Next
From: giozh
Date:
Subject: Re: unable to call a function