Question 25

Table Name: College

Relevant Table: College(Professor (Text), Department (text), Salary (INT))

Professor Department  Salary
John Computer Science 60,000
Van der Mechanical Engineering 57,500
Ackerman Physics 45,000
Suyash Mathematics 52,000
Simrit Computer Science 56,500
Jessica Computer Science 55,000
Jenny Personality Development 50,000

QUERY: Write a query that returns the name and salary of each professor who is either a top 3 or bottom 3 earner.

Execute:      -- Professors in the top 3 earners--
                                SELECT Professor, Salary
                                FROM College
                                ORDER BY Salary DESC
                                LIMIT UNION

                          -- Professors in the bottom 3 earners--
                              SELECT Professor, Salary
                              FROM College
                              ORDER BY Salary ASC
                               LIMIT 3;

Answer:

Professor Salary
John 60000
Van der 57500
Simrit   56500
Ackerman 45000
Jenny     50000
Suyash   52000