Is this query possible in PostgreSQL ?
Is this query possible in PostgreSQL ?
От:
"Ben-Nes Michael" <miki@canaan.co.il>
Дата:
Hi All While reading some SQL books i crossed on SUBSETS querry, but it seems postgres dont understand them. Is there another way to do this in postgres ? if so, where i can read about it ? SELECT * from some_table WHERE MOD(some_row, :n) = 0; Thanks in advance
Re: Is this query possible in PostgreSQL ?
От:
Bruce Momjian <pgman@candle.pha.pa.us>
Дата:
Ben-Nes Michael wrote: > Hi All > > While reading some SQL books i crossed on SUBSETS querry, but it seems > postgres dont understand them. > > Is there another way to do this in postgres ? > if so, where i can read about it ? > > SELECT * from some_table WHERE MOD(some_row, :n) = 0; So this allows you to get every Xth result, like every 3rd row. Wow, that is interesting. We don't have a ROWNUM like Oracle has, but if we did you could just use mod on that: ROWNUM % 3 = 0 You could use a cursor and fetch only every Xth row. Not sure what else I can suggest. -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 853-3000 + If your life is a hard drive, | 830 Blythe Avenue + Christ can be your backup. | Drexel Hill, Pennsylvania 19026
Re: Is this query possible in PostgreSQL ?
От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Bruce Momjian writes: >> SELECT * from some_table WHERE MOD(some_row, :n) = 0; > So this allows you to get every Xth result, like every 3rd row. Wow, > that is interesting. s/interesting/useless/. Every third row in what ordering? And don't tell me about ORDER BY, because WHERE conditions are processed before ORDER BY. regards, tom lane