Search
 
SCRIPT & CODE EXAMPLE
 

SQL

how to find 2nd highest salary in a table

-- 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 2 salary FROM Employee ORDER BY salary DESC 
  ) AS temp 
ORDER BY salary
Comment

PREVIOUS NEXT
Code Example
Sql :: mysql keyword search 
Sql :: mysql join two tables 
Sql :: top 3 salary in sql 
Sql :: android sqlite query join 
Sql :: commit transaction sql 
Sql :: mysql get only the field names in a table 
Sql :: mysql select case insensitive 
Sql :: create db table 
Sql :: mariadb create view 
Sql :: python get backup of sql 
Sql :: max length found in mysql 
Sql :: add column postgresql 
Sql :: export mysql database command line 
Sql :: flask-sqlalchemy filter_by contains 
Sql :: date less than in sql 
Sql :: between date in sql server 
Sql :: open postgresql.conf in centos 
Sql :: wamp server mysql password 
Sql :: convert minutes to hours sql 
Sql :: sql numeric data type 
Sql :: sql use with to get value counts and percentages 
Sql :: check if table is Temporal 
Sql :: mysql get 2nd value in comma separated list 
Sql :: Search In the Database using Text 
Sql :: select all from table left join 
Sql :: alter check constraint in mysql 
Sql :: sql insert into select statement 
Sql :: reindex mssql table 
Sql :: sql server inner join 
Sql :: change column in mysql 
ADD CONTENT
Topic
Content
Source link
Name
1+9 =