Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SELECT *, ROW_NUMBER() OVER in Oracle

Given a working example in T-SQL:

SELECT *, ROW_NUMBER() OVER (ORDER BY name ) as row_id
 FROM 
[schemaName].[Zoo]

If I keep * selector it throws following error ORA-00923: FROM keyword not found where expected.

Is there a way to keep * selector, and make it work in oracle pl/sql? (currently I could achieve wanted result only by mentioning all column names)

like image 503
meta4 Avatar asked Jul 25 '16 11:07

meta4


Video Answer


1 Answers

Try this:

SELECT a.*, ROW_NUMBER() OVER (ORDER BY name ) as row_id FROM schemaName.Zoo a

Here a is alias for table schemaName.Zoo. This will generate all columns from the original table, with row_id column added at the end.

like image 197
Sanjay Radadiya Avatar answered Sep 21 '22 02:09

Sanjay Radadiya