Add a line/row number in front of query results

M

Michael Kintner

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
 
P

Pieter Wijnen

RowNum Sample

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

HTH

Pieter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top