SELECT MAX(Salary) From Employee
WHERE Salary < ( SELECT Max(Salary) FROM Employee);
-- 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
/* 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;
SELECT MAX(SALARY) FROM Employee WHERE SALARY < (SELECT MAX(SALARY) FROM Employee)
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
Code Example |
---|
Sql :: in in sql |
Sql :: execution order in sql |
Sql :: sql server size of every table in a db |
Sql :: datetrunc month sql |
Sql :: create temp table sql |
Sql :: List all the items that have not been part of any purchase order. sql |
Sql :: delete account in flask and sqlalchemy |
Sql :: SQL SUM() Function |
Sql :: SQL Greater than () |
Sql :: rename temp table column name in sql server |
Sql :: sql alias |
Sql :: mysql uuid |
Sql :: mysqldump password in file |
Sql :: sqlalchemy existing db file |
Sql :: how to assign custom id in mysql |
Sql :: grapgql |
Sql :: psql invalid command N |
Sql :: mariadb cast null to 0 |
Sql :: create a database mysql |
Sql :: sql: extract day text from datetime value |
Sql :: foreign key sql |
Sql :: sql recherche nom prenom |
Sql :: apex for oracle 11g |
Sql :: SQL Addition Operator |
Sql :: postgres enumerated type |
Sql :: SQL JOIN and Aliases |
Sql :: ruby sqlite |
Sql :: sql double quotes in string |
Sql :: decimal to integer sql |
Sql :: jsonb |