How do I write a query that outputs the row number as a column? This is DB2 SQL on an iSeries.
eg if I have
table Beatles:
John Paul George Ringo
Check out the row_number() function; you should be able to do this in DB2 via:
SELECT row_number(), first_name FROM beatles
I'm almost certain this is not part of the SQL standard though, so it is not likely to be portable should that ever be an issue.