Search
 
SCRIPT & CODE EXAMPLE
 

SQL

write sql query to find the second highest salary of employee

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

How to find third highest salary in SQL

-- creating Employee table in Oracle
CREATE TABLE Employee (name varchar(10), salary int);

-- inserting sample data into Employee table
INSERT INTO Employee VALUES ('Rick', 3000);
INSERT INTO Employee VALUES ('John', 4000);
INSERT INTO Employee VALUES ('Shane', 3000);
INSERT INTO Employee VALUES ('Peter', 5000);
INSERT INTO Employee VALUES ('Jackob', 7000);

SELECT TOP 1 salary 
FROM (
  SELECT DISTINCT TOP 3 salary FROM Employee ORDER BY salary DESC 
  ) AS temp 
ORDER BY salary
Comment

sql find second highest salary employee

/* 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;
Comment

how to get second highest salary in each department in 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
Comment

Write an SQL query to determine the 5th highest salary without using TOP or limit method.

select min(salary) from (select distinct salary from worker order by salary  desc) where rownum<=5;
Comment

PREVIOUS NEXT
Code Example
Sql :: show all event schedular on mysql 
Sql :: does insert into overwrite sql 
Sql :: t-sql drop function if exists 
Sql :: oracle revoke 
Sql :: drop temp table if exists 
Sql :: postgres list users and roles 
Sql :: connexion mysql 
Sql :: update with join 
Sql :: mysql get latest duplicate rows 
Sql :: varchar vs nvarchar sql 
Sql :: how to extract only year and month from date in sql 
Sql :: do postgresql 
Sql :: check if a column is a primary key in sql server 
Sql :: psql create user 
Sql :: docker create postgresql database 
Sql :: sqlite reset autoincrement 
Sql :: ERROR 1046 (3D000): No database selected 
Sql :: wherein sql 
Sql :: mysql grant select update insert delete 
Sql :: activate log mysql 
Sql :: sql right join with where clause 
Sql :: create table in sql server 
Sql :: mysql query with sql to get the next row 
Sql :: opening xampp mysql in cmd ubuntu 
Sql :: add comma after 3 digits select sql 
Sql :: mysql repeated values 
Sql :: oracle dba_dependencies 
Sql :: sql view talbe columns 
Sql :: df to sql pandas sql achemy 
Sql :: alter table add foreign key mariadb example 
ADD CONTENT
Topic
Content
Source link
Name
2+5 =