"Order By" Clause needn't be added to the end.
I got same result set with and without Order Clause.
Really we needn't use "Order By" Clause again.
1) default order of row_number() window function is in ascending order.
2) default order of partition by emp_no is in ascending order.
3) we also used salary in ascending order in second row_number() function.
This is My answer for Q1. I used subquery that is used just for filtering to know that this employee is manager or not.
select emp_no,salary,row_number() over () as 'Row_Number1',
row_number() over (partition by emp_no order by salary) as 'Row_Number2'
where emp_no in (select emp_no from dept_manager);
Thanks for reaching out.
If you check the first
ROW_NUMBER() column for employee 110085, the salaries are not sorted in ascending way. Example:
110085 68195 43 8
110085 70253 44 9
110085 72335 46 10
110085 72727 45 11
So, you can use the ORDER BY clause.
Hope this helps.
Where is the questions ?! I downloaded the resources ,but I have only answers for the questions !
I need database tables to help my understand