Ad
  • Custom User Avatar

    Please can you post Kata-specific problems on the discourse page for that Kata instead of the forum which is for general topics. Each Kata has an automatic discourse page in which you can mark your comment as a question, which means it's easier for me to help (since it's easier to find). Also, since this is a forum page, I can't mark your comment as a spoiler, meaning people can look at your code and use it themselves, however on the discourse page I can hide your solution.

  • 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