All our Data Science projects include bite-sized activities to test your knowledge and practice in an environment with constant feedback.
All our activities include solutions with explanations on how they work and why we chose them.
List all the unique email addresses from both the customer and staff tables in the Sakila database. Sort the results alphabetically by email address.
Combine first names and last names from both staff and customer tables. Return the columns first_name, last_name, and type. Use aliases to differentiate between staff and customers. Sort the results by last_name, then by first_name.
Retrieve all the dates related to rentals and payments, distinguishing between customer rentals and staff payments.
rental_date (alias for both rental and payment dates)typeCustomer Rental for rental datesStaff Payment for payment datesRetrieve all the first names that are shared by both actors and customers.
first_name columnfirst_nameFetch all the customers who are not also employed as staff members, based on their names. Return the columns first_name and last_name. Sort the results by last_name, then by first_name.
Fetch all the addresses used by both stores and staff, indicating the source of each address.
Return the following columns:
address (from the address table)source (an alias to indicate whether the address is for a Store or Staff)Perform the following joins:
store table with the address table using address_idstaff table with the address table using address_idCombine the results from both queries
Sort the final result by the address column
name (containing either the film title or the actor's full name) and type (indicating whether the entry is a Film or an Actor).name column.city_id values from the address, store, and customer tablescity containing the unique city namesemail: containing the customer's email addressstatus: an alias indicating whether the customer is Active or Inactiveactive column to represent active customers, and 0 for inactive customers.Connect three tables:
film (f): contains film informationfilm_category (fc): links films to their categoriescategory (c): contains category informationReturn two columns:
title: name of the film from the film tablecategory: name of the category from the category tableUse JOIN conditions to link the tables:
film and film_category on film_idfilm_category and category on category_idFilter results using WHERE clause to include only Action and Comedy categories
Order the results first by category name, then by film title
date: containing either the rental_date or return_dateaction: an alias indicating whether the date represents when the film was Rented or Returnedactor, film_actor, film, film_category, and category tables to link actors with film categoriesactor_id: unique identifier for each actorfirst_name: actor's first namelast_name: actor's last nameEXCEPT to exclude actors who have appeared in films with category names Action or ComedyConnect the film table with the inventory table twice:
Return two columns:
film_id: unique identifier for each filmtitle: name of the filmUse JOIN conditions to ensure films are present in both store_id 1 and store_id 2:
i1.store_id = 1 for the first joini2.store_id = 2 for the second joinApply DISTINCT to remove any potential duplicate rows resulting from multiple inventory items per film in each store
Order the final results by film title alphabetically
actor, film_actor, film, film_category, and category tables to link actors with film genresactor_id: unique identifier for each actorfirst_name: actor's first namelast_name: actor's last nameComedy and Drama genresUNION to combine actors from both Comedy and Drama films into a single listDISTINCT to prevent duplicate actor entriescustomer table to check customer activity statuscustomer_id: unique identifier for each customerfirst_name: customer's first namelast_name: customer's last namestatus: custom column labeled either Active or Inactivecustomer_id in ascending order