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

PREVIOUS NEXT
Code Example
Sql :: make date with time sql 
Sql :: mysql import from sql file 
Sql :: athena create table 
Sql :: is sql fast 
Sql :: odd record sql query 
Sql :: insert in to table sql 
Sql :: how to write lowercase in sql 
Sql :: how to find unique key in sql 
Sql :: sql update multiple rows 
Sql :: mysql create user with grant privileges 
Sql :: null column as zero in mysql 
Sql :: oracle simple quote 
Sql :: SQL column name Oracle 
Sql :: SQL Avoid Duplicates in INSERT INTO SELECT 
Sql :: oracle dynamic select into 
Sql :: format the money fied with comma in international system using sql 
Sql :: tablas bootstrap responsive sql server para datos vivos 
Sql :: SQLITE_BUSY: database is locked 
Sql :: functions with parameters SQL 
Sql :: oracle sql average 
Sql :: mysql workbench tutorial 
Sql :: postgresql backup and restore globals and data 
Sql :: how to select month from date in sql 
Sql :: how to insert a uniqueidentifier in sql 
Sql :: oracle pl/sql package 
Sql :: oracle lock user 
Sql :: create unique constraint postgres 
Sql :: oracle get foreign keys on table 
Sql :: mysql unique constraint 
Sql :: display first three characters sql 
ADD CONTENT
Topic
Content
Source link
Name
1+4 =