-- Form to select date range SELECT 'form' AS component, 'multipart/form-data' AS enctype; SELECT 'start_date' AS name, 'date' AS type, 'Start Date' AS label; SELECT 'end_date' AS name, 'date' AS type, 'End Date' AS label; -- Display sales report SELECT 'table' AS component, 'Sales Report' AS title, TRUE AS sort, TRUE AS search; SELECT sale_datetime AS 'Sale Date', printf("%.2f", subtotal) AS 'Subtotal', printf("%.2f", tax) AS 'Tax', printf("%.2f", total) AS 'Total' FROM sales WHERE sale_datetime BETWEEN :start_date AND :end_date AND subtotal IS NOT NULL; -- Calculate total sales for the selected date range WITH total_sales AS ( SELECT SUM(total) AS total_sales FROM sales WHERE sale_datetime BETWEEN :start_date AND :end_date AND subtotal IS NOT NULL ) SELECT 'text' AS component, 'Total Sales: $' || printf("%.2f", total_sales) AS contents FROM total_sales;