SQL for finance: the FP&A and accounting course

Six cases from finance, FP&A and accounting, all on one shared finance database. You write the budget vs actual report, the contribution margin statement, the receivables aging, the cost center analysis, a cash forecast and the month-end reconciliations yourself, one query at a time.

In short: a lot of finance reporting still means exporting data and rebuilding it in a spreadsheet. With SQL you pull the numbers straight from the source, and next month you simply run the same query again. This course drills the queries that come up in finance every single month. Every task is also checked against hidden different data, so typed-in results fail.

Who this course is for

Financial analysts, FP&A teams, accountants, controllers and finance managers who can reach a database, a data warehouse or a BI tool with SQL and don't want to queue for IT every time they need a number. You should be comfortable with SELECT, WHERE, GROUP BY and JOIN. CTEs and window functions are picked up along the way. On the finance side, the course assumes the basics: debits and credits, cost centers, contribution margin.

The practice database

Every case takes place at a made-up maker of bike accessories with eight cost centers. The ledger runs from January to June 2026, the cash plan from July to December. Amounts are net of sales tax or VAT and carry no currency, so they read the same in dollars or pounds. The chart of accounts is simplified and doesn't follow any standard numbering. June deliberately contains a few errors, which you'll track down in the last case.

TableContentsKey columns
cost_centers8 cost centers in 3 departmentscost_center_id, name, department, manager
accountsgeneral ledger accounts with a type (asset, liability, equity, revenue, expense)account_id, name, type
ledger169 journal lines, several per documententry_id, doc_no, entry_date, account_id, cost_center_id, description, debit, credit
budgetcost budget, one row per cost center, months in columnscost_center_id, jan to dec
product_groups, products4 groups with fixed costs, 12 products with price and variable cost per unitgroup_id, fixed_costs; product_id, price, variable_cost
salesunits and revenue per product and monthproduct_id, month, units, revenue
invoices, payments60 customer invoices and the payments against theminvoice_id, customer, invoice_date, due_date, amount
cash_plan, bank_balanceexpected payments July to December, bank balance on 30 Juneexpected_date, direction, category, amount

The ledger is stored as journal lines, as in any accounting system: a document has at least two lines, and each line carries its amount either as a debit or as a credit. That's why costs are always debit - credit: credit notes sit on the credit side.

What you'll be able to do

  • build a budget vs actual report per cost center for one month and year to date, with variance in amount and percent and a flag based on two thresholds;
  • work out contribution margin per product and the margin after fixed costs per product group without a join multiplying those fixed costs;
  • list open receivables as of a cut-off date, pull a dunning list and bucket the balance by age;
  • calculate each cost center's share of total and department costs with window functions and find its largest cost type;
  • build a cash forecast with a running balance and spot the months that fall below the minimum;
  • catch unbalanced documents, expenses with no cost center and gaps between the invoice list and the general ledger at month end.

The six cases

The order follows a month in finance: first the cost and margin reports, then receivables and cost centers, then the look ahead, and finally the checks no report should leave the building without.

  1. Budget vs actual: actuals from the ledger, budget from the month column, variance, percentage and a review flag.
  2. Contribution margin: margin and margin ratio per product, margin after fixed costs per product group.
  3. Receivables aging: open items as of a cut-off date, dunning list and aging buckets with CASE.
  4. Cost centers: share of total and of department, largest cost type per cost center.
  5. Cash flow: inflows and outflows per month, running balance and the minimum balance.
  6. Month-end close: debits equal credits per document, expenses without a cost center, invoices reconciled to the ledger.

Each case has two or three tasks. Above every task you can see the tables with all their rows. "Run" lets you try out steps on the way, and "Check" compares your result with the model answer.

Before you start

Levels 1 to 3 and 5 of the SQL course are a good base, but not required. Wherever a case needs a technique, it links to the lesson, and the hints on each task lead to the answer in three steps. If you'd rather build the same reports in a spreadsheet first, they are in Excel for financial analysts.

The certificate

This course has its own certificate, "SQL for finance and FP&A". You earn it by solving every case task, at least 80% of them without revealing the answer. Your queries are checked on the server, including against the hidden variant data. The certificate shows your name, the date and the list of cases, and comes with a public verification link for job applications or LinkedIn. It's part of Premium and needs a confirmed email address; the first task of every case is free to try. It's a certificate from LearnThisNext, not a qualification from a database vendor or a professional body.

Your progress and the certificate form are in the course view in your account. SQL courses for other roles are listed under SQL intensive courses.

Frequently asked questions

Do financial analysts need SQL?

Not all of them, but more every year. Where the data lives in a data warehouse or an ERP database, SQL saves you the export step and makes your analysis repeatable: the same query gives you next month's numbers. This course covers the queries that come up most often in finance.

Which database do the exercises use?

They run on SQLite on our server, so there's nothing to install. Where MySQL, PostgreSQL or SQL Server differ, for example in date arithmetic or the data type for money, the case page says so.

How long does the course take?

That depends on your experience. There are six cases with 15 tasks in total and no time limit. Your progress is saved, so you can stop and pick up later.

Is the data real?

No. The company, its customers and all amounts are invented. The data is built so that it hangs together: the invoices add up to the revenue postings and the payments to the cash receipts in the bank account. That's exactly why the planted errors in the month-end close stand out.

Can my query look different from the model answer?

Yes. The result is checked, not the wording of the query. Whether you use a CTE, a subquery or a join is up to you, as long as the columns and values match.

Start with case 1: budget vs actual

The cost report for March and the half-year, with variance in percent and a flag that only fires when it matters.

Start case 1

Write to us

Choose language

Select your preferred language