7. Subqueries in FROM and SELECT: nested SELECT statement will in SELECT and FRO
ID: 3602839 • Letter: 7
Question
7. Subqueries in FROM and SELECT: nested SELECT statement will in SELECT and FROM clause SELECT A, A A FROM R1.R.R WHERE condition; Subquery in FROM clause will generate a table: Q1. Students whose scaled GPA changes GPA by more than 1. SELECT sID, sName, GPA, GPA (sizeHS/ 1000) as scaledGPA FROM STUDENT WHERE abs(GPA (sizeHS/ 1000) - GPA)>1.0; SELECT FROM (SELECT SID, SName, GPA, GPA (sizeHS/1000) as scaledGPA FROM STUDENT) G WHERE abs(G.scaledGPA- GPA)> 1.0; Subquery in SELECT clause will generate a value: Q2. Colleges paired with the highest GPA of their applicants. SELECT DISTINCT College.cName, state, GPA FROM College, Apply, Student WHERE College.cName Apply.cName and Apply-SID-Student-sID and GPA >= ALL ( SELECT GPA FROM Student, Apply WHERE Student,sID = Apply.slD and Apply.cName College.cName; SELECT cName, state, (SELECT distinct GPA FROM Apply, Student WHERE College.cName Apply.cName and ApplysID = Student·sID and GPA >ALL SELECT GPA FROM Student, Apply WHERE Student.sID Apply.siD and Apply. cName = College,cName)) as GPA from College;Explanation / Answer
In first query it ia table:
Displays all the records with student details having absolute value of the difference between scaledGPA and GPA.
In the second query only the a value is displayed i.e 1 record with college name(only 1 as distinct is mentioned), state and GPA , where the college have highest GPA of the all colleges. The sub query return the all the GPA's of the colleges where student applied to a particular exam. In the outer query highest of all is selected.
sID sName GPA ScaledGPARelated 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.