| From: | "Al Kirkus" <Al(at)dist102(dot)k12(dot)il(dot)us> |
|---|---|
| To: | pgsql-general(at)postgresql(dot)org |
| Subject: | Probably simple answer |
| Date: | 2001-11-01 20:24:29 |
| Message-ID: | sbe15b53.085@dist102.k12.il.us |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
Hi all.
Can anyone tell me how to get a sequential row count field in the output of a query?
Say I want to query for all users in a table sorted by lastname and firstname.
I would like to include a column in my query called "rownum" which would uniquely identify the row in the order of the query results.
Like this:
rownum =1 lastname=jones, firstname=john
rownum=2 lastname=smith, firstname=john
etc.
I assume rownum should be some kind of function of expresion but I don't know what.
Something like:
Select ???? as rownum, lastname,firstname from users where xxx =xxx order by lastname, firsname.
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Thomas Yackel | 2001-11-01 21:02:06 | Database security in a multi-user environment |
| Previous Message | Andrew Gould | 2001-11-01 19:53:45 | Re: Best way to store/search phone numbers? |