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 :: oracle grant directory 
Sql :: change column name sql 
Sql :: sql date function 
Sql :: sql pivot without aggregate 
Sql :: finish transaction sql 
Sql :: sql remove duplicate 
Sql :: flask connect to mysql 
Sql :: what is relational database 
Sql :: mysql if statement in where clause 
Sql :: BigQuery Remove Duplicate Keys From Table 
Sql :: ImportError: DLL load failed while importing _sqlite3: The specified module could not be found. 
Sql :: alter table query in mysql 
Sql :: sql to c# model 
Sql :: what is cursor in sql server with example 
Sql :: update row postgres 
Sql :: DELETE DUPLICATE VALUES FROM A TABLE IN SQL SERVER 
Sql :: postgres full text search example 
Sql :: mysql sort asc numeric 
Sql :: missing left parenthesis error in sql 
Sql :: forgot postgres password 
Sql :: sql nombre mes mysql 
Sql :: view acl table oracle 
Sql :: show database not empty tables postgres 
Sql :: tsql find procedure with name 
Sql :: How to take sum of column with same id and different table in SQL? 
Sql :: bigquery information_schema schema all columns 
Sql :: sql revert migration 
Sql :: psql initialization 
Sql :: how to assign custom id in mysql 
Sql :: denormalization in sql example 
ADD CONTENT
Topic
Content
Source link
Name
7+7 =