The Rating table has the numVotes and the averageRating for each title. A movie is consider a
Fantastic news! We've Found the answer you've been seeking!
Question:
The Rating table has the numVotes and the averageRating for each title. A movie is consider a "big hit" if there were more than 100,000 votes for the movie. Which movie titles were "big hits"? Construct a query that generates the following result:
isBigHit | total | |
---|---|---|
0 | no | ???? |
1 | yes | ???? |
Where ???? is replaced with the correct values. The row with no should have the count for how many movies are not big hits, and the row with yes should have the count of how many movies are big hits.
Hints:
- While SQL sometimes cast data automatically, it is still best practice to cast string data to numerical data type manually before performing arithmetic operation for the purposes of readability and reproducibility.
- You will need to use some type of JOIN.
- You may also consider using a CASE statement:CASE statements are the SQL-equivalent of Python if... elif... else statements. To read up on CASE, take a look at the following links:
- https://mode.com/sql-tutorial/sql-case/
- https://www.w3schools.com/sql/sql_ref_case.asp
CASE WHEN ... THEN ... ELSE ... END
query_q3 = """
"""
res_q3 = pd.read_sql(query_q3, engine)res_q3
Related Book For
Posted Date: