Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GBQ window function AND arithmetic operations

Does anyone know if it is possible to do any arithmetic operation on a result derived using GBQ window functions?

For example, can I increase row_number by 100 (some number) using pseudocode like this:

SELECT 100 + ROW_NUMBER() OVER (PARTITION BY X ORDER BY x_id DESC) increased_row_num
FROM Table1
...
like image 510
goRunToStack Avatar asked Jul 21 '15 12:07

goRunToStack


1 Answers

You will need to use subquery for that

SELECT 100 + row_num AS increased_row_num FROM (
SELECT ROW_NUMBER() OVER (PARTITION BY X ORDER BY x_id DESC) AS row_num
FROM Table1
)
like image 133
Mosha Pasumansky Avatar answered Oct 13 '22 00:10

Mosha Pasumansky