0% found this document useful (0 votes)
44 views3 pages

EX6

The document creates tables to store movie and box office data. The Movies table stores information about movies like title, director, year, and length. The Boxoffice table stores box office data like ratings and domestic/international sales amounts. Records are inserted into both tables for 14 Disney/Pixar movies. Queries are written to find domestic/international sales by movie, movies where international sales exceeded domestic sales, and movies ordered by rating.

Uploaded by

santhan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views3 pages

EX6

The document creates tables to store movie and box office data. The Movies table stores information about movies like title, director, year, and length. The Boxoffice table stores box office data like ratings and domestic/international sales amounts. Records are inserted into both tables for 14 Disney/Pixar movies. Queries are written to find domestic/international sales by movie, movies where international sales exceeded domestic sales, and movies ordered by rating.

Uploaded by

santhan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

a) Create the "Movies" table:

CREATE TABLE Movies (


Id INT PRIMARY KEY,
Title VARCHAR2(50),
Director VARCHAR2(50),
Year VARCHAR2(4),
"Length mins" INT
);

b) Describe the table "Movies":

DESC Movies;

c) Insert records into "Movies" table:

INSERT ALL
INTO Movies (Id, Title, Director, Year, "Length mins") VALUES (1, 'Toy Story', 'John
Lasseter', '1995', 81)
INTO Movies (Id, Title, Director, Year, "Length mins") VALUES (2, 'A Bug''s Life', 'John
Lasseter', '1998', 95)
INTO Movies (Id, Title, Director, Year, "Length mins") VALUES (3, 'Toy Story 2', 'John
Lasseter', '1999', 93)
INTO Movies (Id, Title, Director, Year, "Length mins") VALUES (4, 'Monsters, Inc.', 'Pete
Docter', '2001', 92)
INTO Movies (Id, Title, Director, Year, "Length mins") VALUES (5, 'Finding Nemo', 'Andrew
Stanton', '2003', 107)
INTO Movies (Id, Title, Director, Year, "Length mins") VALUES (6, 'The Incredibles', 'Brad
Bird', '2004', 116)
INTO Movies (Id, Title, Director, Year, "Length mins") VALUES (7, 'Cars', 'John Lasseter',
'2006', 117)
INTO Movies (Id, Title, Director, Year, "Length mins") VALUES (8, 'Ratatouille', 'Brad Bird',
'2007', 115)
INTO Movies (Id, Title, Director, Year, "Length mins") VALUES (9, 'WALL-E', 'Andrew
Stanton', '2008', 104)
INTO Movies (Id, Title, Director, Year, "Length mins") VALUES (10, 'Up', 'Pete Docter',
'2009', 101)
INTO Movies (Id, Title, Director, Year, "Length mins") VALUES (11, 'Toy Story 3', 'Lee
Unkrich', '2010', 103)
INTO Movies (Id, Title, Director, Year, "Length mins") VALUES (12, 'Cars 2', 'John
Lasseter', '2011', 120)
INTO Movies (Id, Title, Director, Year, "Length mins") VALUES (13, 'Brave', 'Brenda
Chapman', '2012', 102)
INTO Movies (Id, Title, Director, Year, "Length mins") VALUES (14, 'Monsters University',
'Dan Scanlon', '2013', 110)
SELECT * FROM dual;

d) Create the "Boxoffice" table:

CREATE TABLE Boxoffice (


Movie_id INT PRIMARY KEY,
Rating FLOAT,
Domestic_sales INT,
International_sales INT
);

e) Insert records into "Boxoffice" table:

INSERT ALL
INTO Boxoffice (Movie_id, Rating, Domestic_sales, International_sales) VALUES (5, 8.2,
380843261, 555900000)
INTO Boxoffice (Movie_id, Rating, Domestic_sales, International_sales) VALUES (14, 7.4,
268492764, 475066843)
INTO Boxoffice (Movie_id, Rating, Domestic_sales, International_sales) VALUES (8, 8,
206445654, 417277164)
INTO Boxoffice (Movie_id, Rating, Domestic_sales, International_sales) VALUES (12, 6.4,
191452396, 368400000)
INTO Boxoffice (Movie_id, Rating, Domestic_sales, International_sales) VALUES (3, 7.9,
245852179, 239163000)
INTO Boxoffice (Movie_id, Rating, Domestic_sales, International_sales) VALUES (6, 8,
261441092, 370001000)
INTO Boxoffice (Movie_id, Rating, Domestic_sales, International_sales) VALUES (9, 8.5,
223808164, 297503696)
INTO Boxoffice (Movie_id, Rating, Domestic_sales, International_sales) VALUES (11, 8.4,
415004880, 648167031)
INTO Boxoffice (Movie_id, Rating, Domestic_sales, International_sales) VALUES (1, 8.3,
191796233, 170162503)
INTO Boxoffice (Movie_id, Rating, Domestic_sales, International_sales) VALUES (7, 7.2,
244082982, 217900167)
INTO Boxoffice (Movie_id, Rating, Domestic_sales, International_sales) VALUES (10, 8.3,
293004164, 438338580)
INTO Boxoffice (Movie_id, Rating, Domestic_sales, International_sales) VALUES (4, 8.1,
289916256, 272900000)
INTO Boxoffice (Movie_id, Rating, Domestic_sales, International_sales) VALUES (2,

7.2, 162798565, 200600000)


INTO Boxoffice (Movie_id, Rating, Domestic_sales, International_sales) VALUES (13, 7.2,
237283207, 301700000)
SELECT * FROM dual;
f) Find the domestic and international sales for each movie:

SELECT
m.Id,
m.Title,
b.Domestic_sales,
b.International_sales
FROM
Movies m
JOIN
Boxoffice b ON m.Id = b.Movie_id;

g) Show the sales numbers for each movie that did better internationally rather than
domestically:

SELECT
m.Id,
m.Title,
b.Domestic_sales,
b.International_sales
FROM
Movies m
JOIN
Boxoffice b ON m.Id = b.Movie_id
WHERE b.International_sales > b.Domestic_sales;

h) List all the movies by their ratings in descending order:

SELECT
m.Id,
m.Title,
b.Rating
FROM
Movies m
JOIN
Boxoffice b ON m.Id = b.Movie_id
ORDER BY b.Rating DESC;

You might also like