Code using SQL 1 For any faculty member whose supervisor is
Code using SQL
1. For any faculty member whose supervisor is in the same department, list the name of the faculty member, the faculty member\'s department, the name of his or her supervisor.
2. Which faculty members have the same rank as their supervisor? List the name of the faculty member, the rank of the faculty member and the name of his or her supervisor.
3. Which freshmen are on the waiting list directly before seniors?
4. Which student is directly after Peter Garcia on the waiting list?
| faculty_id | faculty_last | faculty_first | rank | department | salary | supervisor_id |
|---|---|---|---|---|---|---|
| 1000 | Doe | John | Full | Administration | $150,000.00 | |
| 1023 | Norris | Bob | Associate | marketing | $80,000.00 | 1000 |
| 1234 | Myers | Susan | Assistant | marketing | $70,000.00 | 1023 |
| 2143 | Birkin | Debra | Full | Information Systems | $85,000.00 | 1000 |
| 2319 | Lysne | John | Associate | Accounting | $100,000.00 | 6547 |
| 2345 | Smith | Phil | Full | Management | $90,000.00 | 1000 |
| 3467 | Berndt | Mike | Assistant | marketing | $75,000.00 | 1023 |
| 4567 | Anderson | Mary | Associate | Information Systems | $90,000.00 | 2143 |
| 4756 | Collins | Rick | Associate | Management | $85,000.00 | 2345 |
| 5678 | Bottelberghe | Dave | Associate | Information Systems | $80,000.00 | 2143 |
| 6547 | Lopez | Judy | Full | Accounting | $100,000.00 | 1000 |
| 7890 | Spears | Bill | Assistant | Accounting | $105,000.00 | 6547 |
| 8901 | Robbins | Becky | Associate | Management | $90,000.00 | 2345 |
| 9012 | Plesant | Tom | Full | Information Systems | $95,000.00 | 2143 |
Solution
1)
SELECT faculty_last,faculty_first,department FROM faculty
WHERE faculty_id==supervisor_id;
--------------------------------------------------------------------------
2)
SELECT faculty_last,faculty_first,rank FROM faculty
WHRER (faculty_id==supervisor_id) and rank
------------------------------------------------------------------------------
3)
