Getting Started with Adobe After Effects - Part 6: Motion Blur


Upload Image Close it
Select File

This challenge is about finding second highest salary for each department

PLSQL Challenge 2 - Find the second highest salary for each department

CTE and Analytic Function

Nov 2 2011 2:16PM by lostformars   

My solution was very similar to another submitted solution. However, I really prefer CTEs over sub queries. Another benefit is Oracle's sub query factoring (not in use here), which will usually be more efficient (but not always!).

with rankedSalaries as (
    select emps.*, dense_rank() over(partition by department order by salary desc) rank
    from PLC2_Employees emps
)
select EmployeeID, EmployeeName, Department, Salary
from rankedSalaries
where rankedSalaries.rank = 2
order by Department, EmployeeID

Tags:


lostformars
878 · 0% · 32
1



Submit

Your Comment


Sign Up or Login to post a comment.

"CTE and Analytic Function" rated 5 out of 5 by 1 readers
CTE and Analytic Function , 5.0 out of 5 based on 1 ratings
    Copyright © Rivera Informatic Private Ltd Contact us      Privacy Policy      Terms of use      Report Abuse      Advertising      [ZULU1097]