“cara mendapatkan gaji tertinggi kedua di setiap departemen di SQL” Kode Jawaban

Tulis kueri SQL untuk menemukan gaji tertinggi kedua dari karyawan

SELECT MAX(Salary) From Employee
 WHERE Salary < ( SELECT Max(Salary) FROM Employee);
Obedient Owl

SQL Temukan karyawan gaji tertinggi kedua

/* sql 2nd highest salary employee */
select sal, ename
from emp
where sal =
    (
        select max(sal) from emp where sal <
            (select max(sal) from emp)
    )
----------------------------------------------- option 2
select *
from 
(
    select ename, sal, dense_rank() over(order by sal desc) rank
    from emp
)
where rank =2;
Wide-eyed Wolf

cara mendapatkan gaji tertinggi kedua di setiap departemen di SQL

SELECT E.Employers_name, E.dep_number, E.salary
FROM Employers E
WHERE 1 = (SELECT COUNT(DISTINCT salary) 
        FROM Employers B 
        WHERE B.salary > E.salary AND E.dep_number = B.dep_number)
group by E.dep_number
Obedient Ocelot

Dapatkan gaji maksimal dari setiap departemen SQL

--Find out the name of top earner in each departments
--Output has Name, Department name and max salary of the department

SELECT E.FIRST_NAME , D.DEPARTMENT_NAME, E.SALARY
FROM EMPLOYEES E
JOIN DEPARTMENTS D ON E.DEPARTMENT_ID = D.DEPARTMENT_ID
WHERE SALARY IN(SELECT MAX(E.SALARY)
FROM EMPLOYEES E
JOIN DEPARTMENTS D ON E.DEPARTMENT_ID = D.DEPARTMENT_ID
GROUP BY DEPARTMENT_NAME);
Obedient Ocelot

Jawaban yang mirip dengan “cara mendapatkan gaji tertinggi kedua di setiap departemen di SQL”

Pertanyaan yang mirip dengan “cara mendapatkan gaji tertinggi kedua di setiap departemen di SQL”

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya