0

How to display min and max salary from a table at a time (2 records at a time, one with max and another with min)?

My input table data:

empid  ename sal
1       A    2000
2       B    1000
3       C    1500
4       D    5000
5       E    7000

Output:

sal
7000 -- max
2000 -- min
Thomas Fritsch
  • 9,639
  • 33
  • 37
  • 49

2 Answers2

0

You mean something like this?

select max(sal) sal from my_table union all select min(sal) sal from my_table
hbourchi
  • 309
  • 2
  • 8
0

You can just use a Union:

Select MAX(Sal)
From TableA

UNION ALL

Select Min(Sal)
From TableA

This would give you your desired output:

sal
7000 -- max
2000 -- min

More information on Unions can be found here.

Tom
  • 12,928
  • 2
  • 15
  • 31