I want to add specific value to the row number but this statement doesn't work :
SELECT (ROW_NUMBER()+1) OVER(ORDER BY col_1 value DESC) as Row FROM table
what is the correct syntax to do it ?
You have to put the addition after the window function, but before the alias.
SELECT ROW_NUMBER() OVER (ORDER BY col_1, value DESC) + 1 as Row FROM table
... or, you can put it at the beginning if it seems clearer:
SELECT 1 + ROW_NUMBER() OVER (ORDER BY col_1, value DESC) as Row FROM table
I also added a comma between col1
and value
. I assume those are 2 different columns, and that it was a typo. Just mentioning for completeness.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.