Od 43) The latsst scoras krom the Japanss Basaball Laague are in tha table with
ID: 3705376 • Letter: O
Question
Od 43) The latsst scoras krom the Japanss Basaball Laague are in tha table with schama ScorsTeam, Day, Opporant, Rurs) Cives the sco in ths Japanese Basaball Lsagus for ewo conecue days. Tha data n this table sas follorwa allows unday Stars allows Bay Stans iants y Stars 5 allows Monday Giants Bay Stars Rers allows 5 Deisrminsthe resuof tha solle query SELECT Team Day FROM Scorss S WHERE NOTEXISTS ISELECT FROM Scors: S2 WHERE St.Runs-S2Runa AND Hint Ivhan ing tunderstand what a query dos, ronw of scoras the asas varlable S1 rafarto ts oftenstowork Inalds-. Thai s, trs understand the subquary. Noice that tha subqusry in this problam has an nput, S1.Day, thats dsbamirad ouiside tha subqueyand depends on wihich Idantlky, tn the below, ora of the tuples in the rt Od all Suriy QUE BTION 12Explanation / Answer
Answer -
( Tigers, Sunday)
select Team, Day
FROM SCORES s1
where not exists (select * from SCORES s2
where s1.Runs = s2.Runs AND
(s1.Team <> s2.Team OR s1.Day <> s2.Day));
In this query, each row from table s1 is compared to all the rows of s2
Inner query checks if row in s1 has same runs as row in s2 AND (team in s1 is not equal to s2 OR day in s1 is not equal to s2)
Now the outer query will select rows which are not returned by inner query because of this statement
(WHERE NOT EXISTS)
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.