rownum
is a reserved word in Oracle-- in Oracle,rownum
is a pseudocolumn that you can reference to get the row number (before ordering) of a result set. That's why you need to change the alias when you convert to Oracle. I would prefer something that was more obviously different fromrownum
--rn
orrnk
are good options.tname
is an alias for the inline view in your query. In Oracle, you cannot use theAS
keyword to assign a table alias (you can optionally use it when defining a column alias which is whyAS rownum1
is valid but you could also get rid of theAS
entirely). In this case, thetname
alias is never used so in Oracle you could omit it. I know in some databases (SQL Server) aliases for inline views are required-- I'm not sure whether DB2 requires the table alias.
It sounds like you modified the query correctly (though I quibble with the alias you chose instead of rownum
).