GithubHelp home page GithubHelp logo

lab-sql-7's Introduction

logo_ironhack_blue 7

Lab | SQL Queries 7

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: DB schema

Instructions

  1. In the table actor, which are the actors whose last names are not repeated? For example if you would sort the data in the table actor by last_name, you would see that there is Christian Arkoyd, Kirsten Arkoyd, and Debbie Arkoyd. These three actors have the same last name. So we do not want to include this last name in our output. Last name "Astaire" is present only one time with actor "Angelina Astaire", hence we would want this in our output list.
  2. Which last names appear more than once? We would use the same logic as in the previous question but this time we want to include the last names of the actors where the last name was present more than once
  3. Using the rental table, find out how many rentals were processed by each employee.
  4. Using the film table, find out how many films were released each year.
  5. Using the film table, find out for each rating how many films were there.
  6. What is the mean length of the film for each rating type. Round off the average lengths to two decimal places
  7. Which kind of movies (rating) have a mean duration of more than two hours?

lab-sql-7's People

Watchers

 avatar  avatar

lab-sql-7's Issues

Task 9

@sandrabosk

Could not find a solution for task 9 that uses the tools learned so far (the suggested solution is not working, since alias and window functions are not supported in 'where' clauses). Workaround would be with subqueries, but it is a topic to be presented in the next unit.

Workaround:
select * from (select rental_id, inventory_id, datediff(return_date, rental_date) num_days, avg(datediff(return_date, rental_date)) over (partition by inventory_id) avg_return_days
from rental) as t
where t.num_days < t.avg_return_days;

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.