Question: You are not allowed to use more than 2 SELECT or use any of these SQL keywords: WITH, EXISTS, COUNT, ORDER BY, ASC, DESC, LIMIT,

You are not allowed to use more than 2 SELECT or use any of these SQL keywords: WITH, EXISTS, COUNT, ORDER BY, ASC, DESC, LIMIT, TOP, NATURAL JOIN, JOIN, ON, SOME, ANY, ALL, row_number, dense_rank. Otherwise, no marks will be given

You are given the following view table which is derived from a university staff table. [12 marks]

CREATE VIEW StaffDeptAge AS SELECT sid, dept, age FROM STAFF;

sid the staff id

dept the code (e.g., CS, EE) of the department that the staff works in

age the age of the staff member

Write only ONE SQL statement to answer the following. For each department, display the department code, and a pair of staff ids (sid). The first (second) sid is the member of staff who is oldest (youngest) among all the members of staff in that department. You can assume that there is only one oldest and one youngest member of staff per department. Your SQL should produce a result table that looks like the one below where sid1 (sid2) is the ids of the first (second) staff id:

example:

dept sid1 sid2
CC s123 s231
EE s421 s152

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!