You are on page 1of 1

Eg for second largest using sub query

salary_master: (Sample Data)

id

name

salary

AAA

20000

BBB

18000

CCC

19000

SELECT MAX(salary) from salary_master

SELECT * from salary_master


where salary < (SELECT MAX(salary) from salary_master)

Output:
id

name

salary

BBB

18000

CCC

19000

Now will process the MAX(salary) instead of * we will get the output Second Largest Value

SELECT MAX(salary) from salary_master


where salary < (SELECT MAX(salary) from salary_master)

Output:
20000

You might also like