SQL Practice Logo

SQLPractice Online

Scenario SQL Question

Customer First Order, Last Order, and Lifespan

Build mastery in Date Operations with this scenario-based SQL challenge and live execution support.

Problem Statement

For each customer, report their first and last order dates, the active lifespan in days, and total order count. Return customer_id, customer_name, first_order, last_order, lifespan_days, total_orders — ordered by lifespan_days DESC, customer_id.

Relevant Tables

customersorders

SQL Concepts Used in This Scenario

Strengthen your understanding with these targeted learning topics: