Ad
  • Custom User Avatar

    SELECT c.customer_id,c.email,COUNT(c.customer_id) AS payments_count,SUM(c.customer_id ) AS total_amount
    FROM customer c JOIN payment p
    ON (c.customer_id = p.customer_id)
    ORDER BY c.customer_id limit 10;

    I have done this for the SQL Basics: Top 10 customers by total payments amount question but it still does not work it also wants to return a float number as well for the total amount

    Overview

    For this kata we will be using the DVD Rental database.

    Your are working for a company that wants to reward its top 10 customers with a free gift. You have been asked to generate a simple report that returns the top 10 customers by total amount spent. Total number of payments has also been requested.

    The query should output the following columns:

    customer_id [int4]
    email [varchar]
    payments_count [int]
    total_amount [float]
    and has the following requirements:

    only returns the 10 top customers, ordered by total amount spent

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution