Loading exercise…
Loading exercise…
Exercises are built for a keyboard. Read the task here, then open this page on a laptop to solve it.
First vs repeat. To tell a customer's first order from the rest, number each customer's orders by date with ROW_NUMBER(): number 1 is the first order, everything after is a repeat. Label the rows with CASE, then group by the label. Numbering beats MIN(date) when a customer has two orders on the same day.
select customer_name, signup_date,
case when row_number() over (partition by segment order by signup_date, customer_id) = 1
then 'first in segment' else 'later' end as signup_type
from customersMarketing asks how much of 2025 revenue came from customers' first orders and how much from repeat business.
Label each completed order 'first' (the customer's earliest completed order; on a same-day tie the lower order_id) or 'repeat'. Return order_type, orders, revenue and avg_order_value (revenue ÷ orders), both 2 decimals.
Loading the Brightline dataset…
Language
Full plan
SQL ✓ · Excel and Power BI also included
Cancel anytime · 14-day full refund · Secure payment by Stripe