Mara Chen, the finance lead at a fictional supply business, needs a March 2026 account report. A previous design joined order lines and credits before grouping, so orders with several of each produced inflated totals.
Deliver a query pack with a report for every account, a total reconciliation, an unknown-account exception list and the two accounts with the largest net sales. Each task replaces or extends your own previous query.
Use orders from March 1 at midnight through, but not including, April 1. Only paid and shipped orders qualify. Subtract known credit amounts, treating an absent or all-NULL credit total as zero for this report. Keep unknown-account orders in control totals and the exception list. They cannot be assigned to a named account. Show accounts with no qualifying orders as zero. Break ranking ties by account id.
Start with an order-grain baseline, then join one credit summary per order. That removes the multiplication between independent detail tables before you write the account report. You don't need order lines for this brief, so leave them out.
The finance total includes orders with an unknown account. The named-account report cannot include those orders without inventing an owner. Keep an exception query so the two totals can be reconciled rather than silently dropping the difference.
Each step carries your previous SQL. Some steps turn the working report into a control query; the final step returns to the complete account handoff. The checker uses new amounts and account assignments on the hidden copy. These are correctness exercises in a workspace modeled on a SQL editor. Any production performance claim needs a separate plan and timing comparison on representative data.
The control total reads the eligible orders before any detail-table join can multiply them.