Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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
Cs s123 s125
EE s231 s321

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

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases On The Web Designing And Programming For Network Access

Authors: Patricia Ju

1st Edition

1558515100, 978-1558515109

More Books

Students also viewed these Databases questions

Question

11. Identify the stage of beyond duality in Gone With the Wind.

Answered: 1 week ago