Re: [GENERAL] How ad an increasing index to a query result?

2009-10-19 Thread Merlin Moncure
On Sun, Oct 18, 2009 at 12:00 PM, Raymond O'Donnell wrote: > On 18/10/2009 11:30, Alban Hertroys wrote: > >> Short of enumerating those results in your application, the easiest >> approach is probably to wrap your query in a join with generate_series >> like so: >> >> SELECT a, s.b >> FROM ( >>  

Re: [GENERAL] How ad an increasing index to a query result?

2009-10-18 Thread Raymond O'Donnell
On 18/10/2009 11:30, Alban Hertroys wrote: > Short of enumerating those results in your application, the easiest > approach is probably to wrap your query in a join with generate_series > like so: > > SELECT a, s.b > FROM ( > SELECT a > FROM table1 > ORDER BY a DESC LIMIT 5 > ) AS t1,

Re: [GENERAL] How ad an increasing index to a query result?

2009-10-18 Thread Thom Brown
2009/10/14 Josip : > Hello, > > Could somebody please try to help me with this problem? > So, let’s say that I have the query: > > CREATE SEQUENCE c START 1; > > SELECT a, nextval('c') as b > FROM table1 > ORDER BY a DESC LIMIT 5; > > I.e., I want to pick the 5 largest entries from table1 and show

Re: [GENERAL] How ad an increasing index to a query result?

2009-10-18 Thread Alban Hertroys
On 14 Oct 2009, at 19:05, Josip wrote: Hello, Could somebody please try to help me with this problem? I.e., I want to pick the 5 largest entries from table1 and show them alongside a new index column that tells the position of the entry. For example: a | b 82 | 5 79 | 4 34 | 3 12

Re: [GENERAL] How ad an increasing index to a query result?

2009-10-17 Thread LaMi
Josip wrote: Hello, Could somebody please try to help me with this problem? So, let’s say that I have the query: CREATE SEQUENCE c START 1; SELECT a, nextval('c') as b FROM table1 ORDER BY a DESC LIMIT 5; I.e., I want to pick the 5 largest entries from table1 and show them alongside a new ind

Re: [GENERAL] How ad an increasing index to a query result?

2009-10-14 Thread Chris Spotts
> > SELECT a, nextval('c') as b > FROM table1 > ORDER BY a DESC LIMIT 5; > > I.e., I want to pick the 5 largest entries from table1 and show them > alongside a new index column that tells the position of the entry. For > example: > > a | b > > 82 | 5 > 79 | 4 > 34 | 3 > 12 | 2 > 11 |

Re: [GENERAL] How ad an increasing index to a query result?

2009-10-14 Thread Andrew Bailey
I found an article that should help you with the answer: http://explainextended.com/2009/05/05/postgresql-row-numbers/ ROWNUM is a very useful pseudocolumn in Oracle that returns the position of each row in a final dataset. Upcoming PostgreSQL 8.4 will have this pseudocolumn, but as for now will

[GENERAL] How ad an increasing index to a query result?

2009-10-14 Thread Josip
Hello, Could somebody please try to help me with this problem? So, let’s say that I have the query: CREATE SEQUENCE c START 1; SELECT a, nextval('c') as b FROM table1 ORDER BY a DESC LIMIT 5; I.e., I want to pick the 5 largest entries from table1 and show them alongside a new index column that