Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions LAB_sql_basicq.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
USE sakila;
SHOW TABLES;
#Display all available tables in the Sakila database.
SELECT * FROM actor;
SELECT * FROM film;
SELECT * FROM customer;
#Retrieve all the data from the tables actor, film and customer
SELECT title FROM film;
#Titles of all films from the film table
SELECT name AS language FROM language;
# List of languages used in films
SELECT first_name FROM staff;
#List of first names of all employees
SELECT DISTINCT release_year FROM film;
#Retrieve unique release years.
SELECT COUNT(*) AS store_count FROM store;
#Determine the number of stores
SELECT COUNT(*) AS employee_count FROM staff;
# Determine the Number of Employees
SELECT COUNT(*) AS available_films FROM film;
#Determine How Many Films Are Available
SELECT COUNT(DISTINCT inventory.film_id) AS rented_films
FROM Rental
JOIN inventory ON rental.inventory_id = inventory.inventory_id;
#Rented Films
SELECT COUNT(DISTINCT last_name) AS distinct_last_names FROM actor;
#Number of Distinct Last Names of the Actors
SELECT title, length
FROM film
ORDER BY length DESC
LIMIT 10;
#Retrieve the 10 longest films.
SELECT actor_id, first_name, last_name
FROM actor
WHERE first_name = 'SCARLETT';
#Actors with the first name "SCARLETT"
SELECT title, length
FROM film
WHERE title LIKE '%ARMAGEDDON%' AND length > 100;
#Retrieve all movies that have ARMAGEDDON in their title (>100min)
SELECT COUNT(*) AS films_with_behind_the_scenes
FROM film
WHERE special_features LIKE '%Behind the Scenes%';
#number of films that include Behind the Scenes content