var sidebar_align = 'right';
var content_container_margin = parseInt('290px');
var sidebar_width = parseInt('270px');
Unanswered: Dense_rank in SQL Server 2005
Hi all ,
I am trying to get SQL Server (2005) equivalent of Oracle's Dense_RANK syntax .
I have the below Query in Oracle which is executable (details are here ):
I came to know that SQL Server 2005 does not support FIRST and LAST clauses .
MIN(salary) KEEP (DENSE_RANK FIRST ORDER BY commission_pct) "Worst",
MAX(salary) KEEP (DENSE_RANK LAST ORDER BY commission_pct) "Best"
GROUP BY department_id;
So i tried to reproduce the SQL Server equivalent by using a subquery in from clause but no success .
Please help me
Describe what you want, rather than posting the Oracle code. I'm sure there is a way to produce the result set in SQL Server.
The above example returns, within each department of the sample table 'employees', the minimum salary among the employees who make the lowest commission and the maximum salary among the employees who make the highest commission .
Dense_rank() will return the rank for the aggregate function MIN(salary), FIRST will take the very first row of the of this result set.
LAST will return the last row of the result set
For more details you can visit
I tried with Dense_rank function in SQL Server, but i don't know how to return FIRST and LAST rows