Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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
CS s123 s231
EE s312 s126

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

Database 101

Authors: Guy Kawasaki

1st Edition

0938151525, 978-0938151524

More Books

Students also viewed these Databases questions

Question

What would I do next and why?

Answered: 1 week ago