Re: query on query
| От | Luca Ferrari |
|---|---|
| Тема | Re: query on query |
| Дата | |
| Msg-id | CAKoxK+45XnSM+XQSEq8vb1owCppQ5v=gnG3CwHxX4E0TTVcboA@mail.gmail.com обсуждение исходный текст |
| Ответ на | query on query (Jayadevan M <jayadevan.maymala@ibsplc.com>) |
| Ответы |
Re: query on query
Re: query on query |
| Список | pgsql-general |
On Fri, Jul 5, 2013 at 5:09 AM, Jayadevan M
<jayadevan.maymala@ibsplc.com> 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
В списке pgsql-general по дате отправления: