Question

Locked

How Add and subtract in query using OVER() function.

By naprico ·
HI all, I have medium knowldeg of SQL queries. The Add and subtract in the following query has been bothering me for two days. Could someone help explain, in detail every part of the query especially workings of + and -:
suppose min year is 1980 and table has a total of 14 rows. How the results from over and row_number functions add corresponding cells?
select
(
year (min(hiredate)over()) -
year (min(hiredate)over())%10
) +
row_number()over(order by hiredate) -1 yr
from emp
The output is:
1980
1981
1982
...
1989
Thank you very much.
Naprico

This conversation is currently closed to new comments.

2 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Answers

Share your knowledge
Back to Web Development Forum
2 total posts (Page 1 of 1)  

Related Discussions

Related Forums