assuming below table;
column name | type
id | int
date | varchar
When I use
SELECT ROWNUMBER() OVER( ORDER BY TYPE_DATE ) as ROWID,
TO_DATE( date, 'mm\dd\yyyy' ) as TYPE_DATE,
*
FROM TABLE
I always get below error:
SQL0104N an expected token "*" was found following .... <select_sublist>
here are three questions:
- Why can’t
*be used here? - Why can’t this new column be used in
OVER() - How can I get the set of second 10 records, order by a formatted column
To answer your first question, it is because you have designated additional columns, and DB2 is unable expand this
*to a column list. You can fix this by adding a table identifierFROM TABLE T, and using the exposed identifier to expand the column listSELECT ..., T.*As you can see on this chart from the Information Center, you can only have EITHER
*OR expressions andexposed-name.*For two and three, the column can’t access the value of a function in the same
SELECTclause by referring to it by its alias. You can push it lower into a sub-select, and then use theOVER()function. You can then get the rows you want by adding aBETWEEN: