I have a table called Orders
in which the data looks like this:
EMpID OrderValue OrderID 1 100 1 2 167 89 ....
There are multiple orders for each empID. What I want is to get output in this form
EMPID RANK VALUETOTAL VALUETHISEMPID 1 1 300 100 4 2 300 50\ .....
If there are multiple EmpID(s) With same ValueThisEmpID then it should get same rank.
I tried
SELECT EmpID,SUM(val) OVER() as VALUETOTAL,SUM(val) OVER(PARTITION BY EmpID)
How can I obtain rank and order it by ValueThisEmpID?