Skip site navigation (1) Skip section navigation (2)

Re: how to get row number in select query

From: Piotr Czekalski <pczekalski(at)techbaza(dot)pl>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: how to get row number in select query
Date: 2011-01-27 15:21:06
Message-ID: 4D418D62.4010906@techbaza.pl (view raw or flat)
Thread:
Lists: pgsql-sql
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.

Regards,

Piotr

-- 

--------------------------------------------------------------
"TECHBAZA.PL" Sp. z o.o.
Technologie WEB, eDB&  eCommerce
OddziaƂ Gliwice
ul. Chorzowska 50
44-100 Gliwice
tel. (+4832) 7186081
fax. (+4832) 7003289



In response to

Responses

pgsql-sql by date

Next:From: Thomas KellererDate: 2011-01-27 15:30:02
Subject: Re: how to get row number in select query
Previous:From: Oliveiros d'Azevedo CristinaDate: 2011-01-27 15:02:24
Subject: Re: how to get row number in select query

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group