Skip to content
Advertisement

How to make a start on this SQL query homework? [closed]

A movie streaming app is currently being developed by a start-up. A movie can belong to one or more genres. Given below is the table definitions for movies and genres:

A particular search parameter requires all movies which belong to more than two genres and none of the genres are ‘Comedy’.

Write a query for the above criteria that returns:

The movie’s name. The number of genres the movie belongs to.

write the query considering all scenarios: I have written this query but i am not able to satisfy one test case:

Mentioned below is the test case that I am missing:

Advertisement

Answer

This solution uses a subquery and a variable (tested in sql server):

I guess you could decide to not use the variable and use the ‘Comedy’ string directly in the subquery as well, like this:

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement