Skip to content
Exercises · Q4
Q.

Consider the following MOVIE database and answer the SQL queries based on it.

MovieIDMovieNameCategoryReleaseDateProductionCostBusinessCost
001Hindi_MovieMusical2018-04-23124500130000
002Tamil_MovieAction2016-05-17112000118000
003English_MovieHorror2017-08-06245000360000
004Bengali_MovieAdventure2017-01-0472000100000
005Telugu_MovieAction-100000-
006Punjabi_MovieComedy-30500-

a) Retrieve movies information without mentioning their column names.

b) List business done by the movies showing only MovieID, MovieName and BusinessCost.

c) List the different categories of movies.

d) Find the net profit of each movie showing its ID, Name and Net Profit.

(Hint: Net Profit = BusinessCost – ProductionCost)

Make sure that the new column name is labelled as NetProfit. Is this column now a part of the MOVIE relation. If no, then what name is coined for such columns? What can you say about the profit of a movie which has not yet released? Does your query result show profit as zero?

e) List all movies with ProductionCost greater than 80,000 and less than 1,25,000 showing ID, Name and ProductionCost.

f) List all movies which fall in the category of Comedy or Action.

g) List the movies which have not been released yet.

Puducherry TnboardTextbookSubjective· 4mImportance★★★★★
67% · 30/45 Questions
🔒 Locked · start free trial →

You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.

Start your 14-day free trial to unlock the full solution →

Seven classic single-table queries on MOVIE: SELECT * (all columns), a projection list, DISTINCT for categories, a derived column BusinessCost - ProductionCost AS NetProfit (not stored in the relation; NULL — not zero — for unreleased movies), a range with AND, a set filter with IN, and IS NULL for the not-yet-released rows.

A reading note first: the dashes in the table mean the value is NULL (unknown) — ReleaseDate and BusinessCost are NULL for movies 005 and 006. That drives parts (d) and (g).

a) All movie information, without naming columns

SELECT * FROM MOVIE;
MovieIDMovieNameCategoryReleaseDateProductionCostBusinessCost
001Hindi_MovieMusical2018-04-23124500130000
002Tamil_MovieAction2016-05-17112000118000
003English_MovieHorror2017-08-06245000360000
004Bengali_MovieAdventure2017-01-0472000100000
005Telugu_MovieActionNULL100000NULL
006Punjabi_MovieComedyNULL30500NULL

* is exactly the "don't mention the column names" device — it expands to all columns.

b) Business done — only MovieID, MovieName, BusinessCost

SELECT MovieID, MovieName, BusinessCost FROM MOVIE;
MovieIDMovieNameBusinessCost
001Hindi_Movie130000
002Tamil_Movie118000
003English_Movie360000
004Bengali_Movie100000
005Telugu_MovieNULL
006Punjabi_MovieNULL

Listing column names after SELECT projects just those columns.

c) The different categories

SELECT DISTINCT Category FROM MOVIE;
Category
Musical
Action
Horror
Adventure
Comedy

DISTINCT collapses duplicates — Action appears in two rows but is listed once.

d) Net profit of each movie

SELECT MovieID, MovieName,
       BusinessCost - ProductionCost AS NetProfit
FROM MOVIE;
MovieIDMovieNameNetProfit
001Hindi_Movie5500
002Tamil_Movie6000
003English_Movie115000
004Bengali_Movie28000
005Telugu_MovieNULL
006Punjabi_MovieNULL

Three sub-questions hide here:

  • Is NetProfit now part of the MOVIE relation? No. It is computed on the fly for this result only; AS NetProfit merely labels the output column. Such columns are called derived (computed/virtual) columns — the table itself is unchanged.
  • Profit of an unreleased movie? Its BusinessCost is NULL, and any arithmetic with NULL yields NULL — so NULL - 100000 is NULL.
  • Does the result show zero? No — it shows NULL, which is the honest answer: the profit is unknown, not zero.

e) ProductionCost between 80,000 and 1,25,000 (exclusive)

SELECT MovieID, MovieName, ProductionCost
FROM MOVIE
WHERE ProductionCost > 80000 AND ProductionCost < 125000;
MovieIDMovieNameProductionCost
001Hindi_Movie124500
002Tamil_Movie112000
005Telugu_Movie100000

AND requires both bounds to hold; 004 (72000) falls below and 003 (245000) above. …

Unlock everything free for 14 days

  • Full step-by-step solutions
  • Concept-first explanations
  • Methods, shortcuts & mistakes
  • PYQ mapping + timed mock tests

Full access for 14 days. No credit card required.