Cash flow is the lifeblood of any SaaS (Software as a Service) business. When clients fail to pay their subscription invoices on time, it can disrupt operations and necessitate intervention from the billing or customer success teams. The Finance department needs a routine report of all outstanding invoices that have passed their due date. This data will allow the automated dunning system to send reminder emails to the appropriate clients and help the account managers prioritize their outreach. You have been provided with the invoices table. The key columns to understand are invoice_id (unique identifier for the bill), client_id (identifier for the customer), amount (the invoice total in dollars), status (current state of the bill, such as 'Paid', 'Unpaid', or 'Cancelled'), and due_date (the final deadline for payment). Write a query to extract the overdue invoices for the Finance team. Please ensure your output strictly adheres to the following conditions: Return only the invoice_id , client_id , and amount columns. Filter the results to include only invoices with a status of exactly 'Unpaid'. Only include invoices where the due_date is strictly before '2026-04-12' (treating this as the current date for the exercise). Order the final results by the due_date in ascending order, so the oldest and most overdue invoices appear at the very top. Common Pitfall: Be careful when dealing with boundaries in date comparisons. Because we are looking for invoices that are already overdue, the due date must be strictly less than the evaluation date, so avoid using the less-than-or-equal-to operator. Hint: You will need to use the < operator for the date evaluation and combine your filters using the AND keyword in the WHERE clause.
Table Setup (SQL Schema)
CREATE TABLE invoices (invoice_id INT PRIMARY KEY, client_id INT, amount DECIMAL(10,2), status VARCHAR(20), due_date DATE); INSERT INTO invoices (invoice_id, client_id, amount, status, due_date) VALUES (1, 201, 299.99, 'Unpaid', '2026-04-10'), (2, 202, 499.00, 'Paid', '2026-04-08'), (3, 203, 150.00, 'Unpaid', '2026-04-15'), (4, 204, 99.00, 'Unpaid', '2026-04-01'), (5, 205, 5000.00, 'Cancelled', '2026-04-05'), (6, 206, 350.00, 'Unpaid', '2026-04-11');