Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
2. What will I learn?

Instruction

At the end of this course, you will be able to write complex window function examples with ease. Just take a look at this query, which allows us to see the sum of payments a given person made, and the fourth largest value of the sum of payments as a separate column:

SELECT
  first_name,
  last_name,
  SUM(payment_amount),
  NTH_VALUE(SUM(payment_amount),4) OVER(ORDER BY 
    SUM(payment_amount)
    ROWS BETWEEN UNBOUNDED PRECEDING 
      AND UNBOUNDED FOLLOWING)
FROM single_rental
JOIN customer
  ON customer.id=single_rental.customer_id
GROUP BY first_name, last_name;

Such queries won't be a problem for you at all! But, as we mentioned previously, there are some prerequisites. Precisely speaking, you need to know how to retrieve data from a single table, from multiple tables (with JOINs), how to use ORDER BY, GROUP BY and HAVING.

We've decided to prepare a short quiz for you that will test your skills. The rule is simple: if you know the right answers to all the questions, this course is right for you! Don't worry, you won't have to write much: the quiz is going to be short and painless.

First, let's take a look at the tables we'll use for the quiz. We're going to work with dogs and their owners.

Exercise

Select all the information from the person table.

Each person has a id, first and last name and their age.