From: | Emi Lu <emilu(at)encs(dot)concordia(dot)ca> |
---|---|
To: | Thomas Kellerer <spam_eater(at)gmx(dot)net> |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: how to get row number in select query |
Date: | 2011-01-31 16:39:32 |
Message-ID: | 4D46E5C4.8070208@encs.concordia.ca |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Ok, before 8.4, there I can use row_number().
For 8.3 + display tag + order by integer + paging based on pageBean
ArrayList<Bean> alist;
In Bean.java, added:
private int rec_num;
in main .action java:
for(int i=0 ; i<alist.size; i++)
{
Bean(i).setRec_num = (i+1);
...
}
This will let displaytag show rec num successfully.
--
Lu Ying
On 01/27/2011 10:30 AM, Thomas Kellerer wrote:
> Piotr Czekalski, 27.01.2011 16:21:
>> Gentelmen,
>>
>> I follow this thread and I don't exactly get an idea of yours, but
>> isn't is as simple as (example: table "web.files" contains one column
>> named "fileurl" ):
>>
>> select row_number() over(), X.fileurl from (select fileurl from
>> web.files order by fileurl) X
>>
>> The only disadvantage is that if you do want to order resultset you
>> have to use "select from select" as numbers are added before order
>> which may cause some performance troubles.
>>
>
> You can get the row_number() without using the sub-select and without
> ordering the whole result as you can specify the order in the over()
> clause:
>
> select fileurl
> row_number() over (order by fileurl)
> from web.files
>
> Regards
> Thomas
>
>
--
Emi Lu, ENCS, Concordia University, Montreal H3G 1M8
emilu(at)encs(dot)concordia(dot)ca +1 514 848-2424 x5884
From | Date | Subject | |
---|---|---|---|
Next Message | Oliveiros d'Azevedo Cristina | 2011-01-31 16:51:05 | Re: Get days between two dates? |
Previous Message | Kenneth Marshall | 2011-01-31 16:39:27 | Re: Get days between two dates? |