Add a line/row number in front of query results

  • Follow


How can a add a line number in front of the returned query results?

Example:  If a query returns 3 records:
Dog
Cat
Mouse

I would like to query to return the results with line numbers:
1 Dog
2 Cat
3 Mouse

The query would add line/row numbers for the returned results.

Thank you in advance, I have asked this question in the past but having a 
hard time in trying to explain this simple concept or maybe its not so 
simple.

Michael Kintner 


0
Reply Michael 10/11/2007 3:06:02 PM

RowNum Sample

SELECT  (SELECT COUNT(*)+1 FROM PERMISSIONS P1 WHERE P1.ID < P.ID) AS 
ROWNUM, P.*
FROM PERMISSIONS P

HTH

Pieter

"Michael Kintner" <michaelkintner@nospam.com> wrote in message 
news:13gseuq3osdpe58@corp.supernews.com...
> How can a add a line number in front of the returned query results?
>
> Example:  If a query returns 3 records:
> Dog
> Cat
> Mouse
>
> I would like to query to return the results with line numbers:
> 1 Dog
> 2 Cat
> 3 Mouse
>
> The query would add line/row numbers for the returned results.
>
> Thank you in advance, I have asked this question in the past but having a 
> hard time in trying to explain this simple concept or maybe its not so 
> simple.
>
> Michael Kintner
> 


0
Reply Pieter 10/11/2007 3:15:53 PM


1 Replies
2842 Views

(page loaded in 0.001 seconds)

Similiar Articles:
















7/23/2012 9:11:03 PM


Reply: