Consider the two tables ‘MOVIES’ and ‘SCREENS’ provided below. Table: MOVIES…
2026
Consider the two tables ‘MOVIES’ and ‘SCREENS’ provided below.
Table: MOVIES
MovieID | MovieTitle | ReleaseDate | ScreenNo |
|---|---|---|---|
2026103 | Chhaava | 2025-12-09 | S2 |
2026112 | Dragon | 2026-02-01 | S2 |
2025125 | Ikkis | 2026-01-12 | S1 |
Table: SCREENS
ScreenNo | ScreenSize | TotalSeats |
|---|---|---|
S1 | 60 | 380 |
S2 | 70 | 540 |
Note: Both tables include more relevant rows.
Write MySQL queries to perform the specified tasks:
(A) Display the MovieTitle and the TotalSeats of the screen assigned to each movie.
(B) Display the MovieTitle and ScreenSize of all movies, sorted in descending order of their TotalSeats.
(C) Display the ScreenNo, TotalSeats, and the total count of movies assigned to each screen.
(D) Display each unique year from the ReleaseDate along with the sum of TotalSeats available for movies released in those years.
Show answer & explanation
(A)
SELECT MovieTitle, TotalSeats
FROM MOVIES M, SCREENS S
WHERE M.ScreenNo = S.ScreenNo;(B)
SELECT MovieTitle, ScreenSize
FROM MOVIES M, SCREENS S
WHERE M.ScreenNo = S.ScreenNo
ORDER BY TotalSeats DESC;(C)
SELECT S.ScreenNo, TotalSeats, COUNT(*) AS TotalMovies
FROM MOVIES M, SCREENS S
WHERE M.ScreenNo = S.ScreenNo
GROUP BY S.ScreenNo, TotalSeats;(D)
SELECT YEAR(ReleaseDate) AS Year, SUM(TotalSeats)
FROM MOVIES M, SCREENS S
WHERE M.ScreenNo = S.ScreenNo
GROUP BY YEAR(ReleaseDate);Conclusion: JOIN links tables, while GROUP BY and ORDER BY help in analysis and sorting.