LIMIT between some column

From: Uros Gruber <uros(at)sir-mag(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: LIMIT between some column
Date: 2002-05-19 14:30:12
Message-ID: 9218284842.20020519163012@sir-mag.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi!

My query is

SELECT id_category,name FROM categories WHERE level BETWEEN 1
AND 2 AND lft>1 AND rgt<100 AND active=true ORDER BY name

This is about 30 or more records. This records can be grouped
by id_parent. What i want to do is limit data in a way that i
could get for example only 3 or 4 records with same
id_parent.

here is some data for explanation.

id | parent |
0 | |
1 | 0 |
2 | 0 |
3 | 0 |
4 | 0 |
5 | 1 |
6 | 1 |
7 | 1 |
8 | 1 |
9 | 2 |
10 | 2 |
11 | 3 |
12 | 4 |
13 | 4 |
14 | 4 |
15 | 4 |
16 | 4 |

When i execute my query i get all ids from 5 to 16, but i
want it to limit somehow that i get only ids,
5,6,7,9,10,11,12,13,14. I hope my problem is understandable.
Do I have to use join on table itself or how.

--
lp,
Uros mailto:uros(at)sir-mag(dot)com

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Neil Conway 2002-05-19 14:31:36 Re: sun solaris & postgres
Previous Message TPCCUVA 2002-05-19 14:15:58 space on disk of a table.