You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-- You are given 2 tables, One containing the available Books and the other containing the Books that have been bought by a customer. You have to find the Id’s of all the ‘Famous’ Books. A book is called ‘Famous’ if it is bought by at least 3 customers.
-- my approach :
SELECT b.Id as Id
FROM Books b JOIN BoughtBooks bb ON b.Id=bb.BooksId
GROUP BY bb.BooksId
HAVING COUNT(bb.Id) >= 3
-- more easy solution: no need for the first table.