This is a pure SQL assignment. Submit the assignment as PDF of the notebook using SQL Magic or as a simple text file containing the SQL code for each problem.
We will work with two database on the server: shared_sales
and shared_sakila
.
The sales database closely matches the sales database from John L. Viescas' "SQL Queries for Mere Mortals" https://learning.oreilly.com/library/view/sql-queries-for/9780134858432/
You can review chapters 4, 5, and 6 for additional explanations of SQL queries.
Use the SQL SHOW SCHEMAS
and SHOW TABLES
and SHOW CREATE TABLE
commands to understand the structure of the data in the database.
You can use diagramming software to learn the schema.
These queries will contain only one select statement with no joins or groupings. Some queries will require a subquery in the WHERE
clause.
Finally, make sure that your submission is easy to understand. Include the problem statement in a comment preceding your solution.
Show the names and addresses of all employees
Show the vendor names sorted by state and city.
Show all products, but display their price reduced by 5%.
Show the list of orders made by each customer in descending order date. Hint: you might need to order by more than one column. You do not need to include the customers' names -- the customer ID will suffice.
List the five most expensive products.
List the total value of each product's stock (price x quantity)
List all products that have never been sold.
List all movies over 3 hours in length
List all movies containing the substring "GUMP" in them
List the last rental date for customer 148.
List the titles of all movies in the "Horror" category in alphabetical order
List all actors who have acted in horror movies.