D427 - Lab Practice Guide
D427 - Lab Practice Guide
SELECT
m.Title,
COALESCE(ys.TotalGross, 0) AS TotalGross
8.16
FROM Movie m
LEFT JOIN YearStats ys ON m.Year = ys.Year
ORDER BY m.Title;
SELECT COUNT(*)
8.17 FROM Movie
WHERE Year = '2019';
PA Question PASS/FAIL
Write a SQL statement to create the Member table.
Write a SQL statement to add the Score column to the Movie table.
Write a SQL statement to delete the view named MovieView from the database.
Write a SQL statement to modify the Movie table to make the ID column the
primary key.
Write a SQL statement to designate the Year column in the Movie table as a
foreign key to the Year column in the YearStats table.
Write a SQL statement to create an index named idx_year on the Year column of
the Movie table.
Write a SQL statement to insert the indicated data into the Movie table.
Write a SQL statement to delete the row with the ID value of 3 from
the Movie table.
Write a SQL statement to update the Year value to be 2022 for all movies with
a Year value of 2020.
Write a SQL query to return all data from the Movie table without directly
referencing any column names.
Write a SQL query to retrieve the Title and Genre values for all records in the
Movie table with a Year value of 2020. Ensure your result set returns the columns
in the order indicated.
Write a SQL query to display all Title values in alphabetical order A–Z.
Write a SQL query to output the unique RatingCode values and the number of
movies with each rating value from the Movie table as RatingCodeCount. Sort the
results by the RatingCode in alphabetical order A–Z. Ensure your result set
returns the columns in the order indicated
Write a SQL query to display both the Title and the TotalGross (if available) for all
movies. Ensure your result set returns the columns in the order indicated.
Write a SQL query to return how many movies have a Year value of 2019.