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 (
>>
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,
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
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
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
>
> 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 |
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
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