Using the below University schema, write a SQL query that returns the pair of Fi
ID: 3757094 • Letter: U
Question
Using the below University schema, write a SQL query that returns the pair of FirstName for Students who are enrolled in the exactly same courses. The resultant relation will list a pair once, having the alphabetically smaller Firstname in first column and the alphabetically bigger Firstname in second column, e.g., a tuple consisting of firstanmes 'Abcd' and 'Efg' will have 'Abcd' in first column and 'Efg' in second column. Also, the resultant relation will not have self pairs (a self pair involves two FirstNames of a single student). Input Format The Students, Enrollments and Courses table are defined as follows: Students Column Name Netld FirstName Type VARCHAR(10) VARCHAR(255) VARCHAR(255) LastName Department VARCHAR(100)Explanation / Answer
SELECT S1.FirstName, S2.FirstName
FROM Students S1, Enrollments E1, Students S2, Enrollments E2
WHERE S1.NetId = E1.NetId AND S2.NetId = E2.NetId AND E1.CRN = E2.CRN AND S1.FirstName < S2.FirstName;
Let me know if you have any clarifications. Thank you...
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.