Search Postgresql Archives

Re: query on query

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

 



On Fri, Jul 5, 2013 at 5:09 AM, Jayadevan M
<jayadevan.maymala@xxxxxxxxxx> wrote:

>
> 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;

Luca


-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general




[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