How to number rows in SQL?
Posted in 2004
Topics: Stored Procedures & SPL, Server Administration, Versions, Editions & End-of-Life
Has anyone tryed to number the result set of a sql in dbaccess for example?
I mean:
select <number> no, colA, colB, etc
from some table
What I want to be returned is :
no colA colB etc
-- ---- ---- ----
1 data data data
2 data data data
3 data data data
4 data data data
5 data data data
6 data data data
.
.
.
I'm using IDS 9.3
I know I could what I explained with a stored procedure, but I wonder if there
is a magical function or trick that could be used to achieve what I want in
sql.
Any help would be very appreciated.
Chucho!
Jean Sagi
jeansagi@myrealbox.com
jeansagi@netscape.net
You can
do it in two stages:
select (0::serial +1) no, colA, colB, etc
from some table into temp tempmiketab;
select * from tempmiketab;
Mike
At 04:20 PM 4/20/04, Jean Sagi wrote:
>Has anyone tryed to number the result set of a sql in dbaccess for example?
>
>I mean:
>
>select <number> no, colA, colB, etc
>from some table
>
>What I want to be returned is :
>
>no colA colB etc
>-- ---- ---- ----
>1 data data data
>2 data data data
>3 data data data
>4 data data data
>5 data data data
>6 data data data
----------------------------------------
Michael Dunham-Wilkie, M.Sc., M.P.A.
Senior Database Analyst
Barrodale Computing Services Ltd.
Tel: (250) 472-4372 Fax: (250) 472-4373
Web: http://www.barrodale.com
Email: mike@barrodale.com
----------------------------------------
Mailing Address:
P.O. Box 3075 STN CSC
Victoria BC Canada V8W 3W2
Shipping Address:
Hut R, McKenzie Avenue
University of Victoria
Victoria BC Canada V8W 3W2
----------------------------------------