From: Emi Lu <emilu@encs.concordia.ca>
To: Thomas Kellerer <spam_eater@gmx.net>
Cc: pgsql-sql@postgresql.org
Subject: Re: how to get row number in select query
Date: Mon, 31 Jan 2011 11:39:32 -0500
Message-ID: <4D46E5C4.8070208@encs.concordia.ca> (raw)
In-Reply-To: <ihs31q$1lm$1@dough.gmane.org>
References: <4D4047C1.5030208@encs.concordia.ca>
<D25246ED495942DD8E5777F5F9439DD0@marktestcr.marktest.pt>
<4D4181E9.2000305@encs.concordia.ca>
<090BC28FACC442EAA5D46B58F55480AE@marktestcr.marktest.pt>
<4D418D62.4010906@techbaza.pl>
<ihs31q$1lm$1@dough.gmane.org>
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@encs.concordia.ca +1 514 848-2424 x5884
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: emilu@encs.concordia.ca, spam_eater@gmx.net
Subject: Re: how to get row number in select query
In-Reply-To: <4D46E5C4.8070208@encs.concordia.ca>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox