Closed GaoyanCheerup closed 5 years ago
Similar cases, why the SQL of this sentence is T1.customer_id instead of T2.customer_id: Return the id and full name of the customer who has the fewest accounts. SELECT T1.customer_id , T2.customer_first_name , T2.customer_last_name FROM Customers_cards AS T1 JOIN Customers AS T2 ON T1.customer_id = T2.customer_id GROUP BY T1.customer_id ORDER BY count(*) ASC LIMIT 1
Hi,
We accept the foreign keys in both tables in our evaluation. So both T1.customer_id and T2.customer_id work.
Best, Tao
For this question below, why it is labeled as the first SQL, instead of the second one: What are the names and ids of artists with 3 or more albums, listed in alphabetical order? SELECT T2.Name , T1.ArtistId FROM ALBUM AS T1 JOIN ARTIST AS T2 ON T1.ArtistId = T2.ArtistID GROUP BY T1.ArtistId HAVING COUNT() >= 3 ORDER BY T2.Name SELECT T2.Name , T2.ArtistId FROM ALBUM AS T1 JOIN ARTIST AS T2 ON T1.ArtistId = T2.ArtistID GROUP BY T1.ArtistId HAVING COUNT() >= 3 ORDER BY T2.Name
Thanks :)