Search
 
SCRIPT & CODE EXAMPLE
 

SQL

3rd highest value 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

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

PREVIOUS NEXT
Code Example
Sql :: postgresql function 
Sql :: SQL ORDER BY ASC (Ascending Order) 
Sql :: drop sequence 
Sql :: csv into data postgres 
Sql :: sql substring 
Sql :: update con select postgresql 
Sql :: sqlite3 import csv 
Sql :: postgresql remove new line from string 
Sql :: creating a table sql 
Sql :: count in sql and diff 
Sql :: json with root element in sql server 
Sql :: flask sqlalchemy update row 
Sql :: python uuid sqlalchemy 
Sql :: how to get the date diff of 2 dates in the same fieldin sql server 
Sql :: sql order by multiple columns 
Sql :: how to change column name in mysql 
Sql :: row to json in sql server 
Sql :: display all node label neo4j 
Sql :: update sqlite 
Sql :: tinydb add table 
Sql :: sub query in linq 
Sql :: select random rows sql 
Sql :: activate binary log mariadb 
Sql :: postgres trigger insert into another table 
Sql :: laravel eloquent get generated sql 
Sql :: sql select where clause 
Sql :: SQL column name Oracle 
Sql :: insert into without column names 
Sql :: How to import CSV file into a MySQL table 
Sql :: SQL SELECT DISTINCT Statement 
ADD CONTENT
Topic
Content
Source link
Name
2+4 =