Skip to content

jecastrom/lab-sql-4

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 

Repository files navigation

Lab SQL Queries 4

Jorge Castro DAPT NOV2021

Lab with solutions

In this lab, you will be using the Sakila database of movie rentals. You have been using this database for a couple labs already, but if you need to get the data again, refer to the official installation link.

The database is structured as follows:

Drawing



Instructions (Go to)

Solutions:

  1. Get film ratings

SELECT
    DISTINCT rating
FROM
    film;

Drawing

Go to top

  1. Get release years

SELECT
    DISTINCT release_year
FROM
    film;

Drawing

Go to top

  1. Get all films with ARMAGEDDON in the title.

SELECT
    title
FROM
    film
WHERE
    title LIKE '%armageddon%';

Drawing

Go to top

  1. Get all films with APOLLO in the title

SELECT
    title
FROM
    film
WHERE
    title REGEXP 'apollo';

Drawing

Go to top

  1. Get all films which title ends with APOLLO

SELECT
    title
FROM
    film
WHERE
    title REGEXP 'apollo$';

Drawing

Go to top

  1. Get all films with word DATE in the title

SELECT
    title
FROM
    film
WHERE
    title REGEXP 'date';

Drawing

Go to top

  1. Get 10 films with the longest title

SELECT
    title,
    length(title) AS titles_length
FROM
    film
ORDER BY
    length(title) DESC
LIMIT
    10;

Drawing

Go to top

  1. Get 10 the longest films

SELECT
    title,
    length
FROM
    film
ORDER BY
    length DESC
LIMIT
    10;

Drawing

Go to top

  1. How many films include Behind the Scenes content

SELECT
    title AS 'Film Title',
    special_features AS 'Films with Behind the Scenes content'
FROM
    film
WHERE
    special_features REGEXP 'behind the scenes';

Drawing

Go to top

  1. List films ordered by release year and title in alphabetical order

SELECT
    release_year,
    title
FROM
    film
ORDER BY
    title ASC;

Drawing

SQL Lab 4 solutions script only on .sql file CLICK HERE

Go to top

About

SQL Lab 4 with solutions

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published