Start here
Lessons and reference
Look things up
Start here
SQL
Power Query
Data modeling
Power BI and DAX
Finance playbooks
Run queries
Build and check
Ready-to-run SQL for month-end close, receivables, payables, cash, margin, budgets, controls, payroll, nonprofit and inventory, on live sample data.
No recipe matches that search. Clear the search or choose another topic.
Find a finance question by word or topic.
Each one explains the question, how to read the answer and what to watch for.
Run it in the playground or on your own database.
Each recipe answers a finance or accounting question with SQL against one of the free sample databases on LearnSQL. Press Run it and the query executes live, read-only, so the result is the current data in the sample rather than a screenshot.
Every recipe has two versions, one for SQL Server and one for MariaDB (MySQL). They ask the same question and return the same kind of answer. Copy the version that matches your database system. The SQL Server version names each table with its schema, such as dbo.invoices, or with the database name where a sample uses that layout, such as classicmodels.orders. The MariaDB version uses plain table names because the database is selected on the connection.
Start with the business question. The "What to look for" note tells you how to read the output. The "Watch out for" list names the mistakes people make with that kind of question: which rows are left out, which dates are used, and where the totals can mislead.
The sample dates move forward every day, so anything described as "as of today" or "last twelve months" changes when you run it again. The recipes are written to stay correct as the dates move. The text never quotes a number from a run, so check each result yourself.
Treat a recipe as a starting point. Replace the sample table and column names with your own, check the join keys and sign conventions in your system, and tie the total to a report you already trust before you use it for a decision. A trial balance whose debits and credits do not agree, or an aging that does not tie to the receivable account, usually means a join or a filter is wrong.
This page shows at most 200 rows of each result.
Yes. Copy the SQL into the SQL tool you already use and connect with the sample database settings. The sample logins are read-only, so an edit cannot change the data. For a guided version, try the visual SQL builder.
SQL Server and MariaDB use different functions for dates, for limiting rows and for joining text. Each version uses the native function. For example, SQL Server writes DATEDIFF with the unit first, and it limits rows with TOP while MariaDB uses LIMIT at the end of the query.
Many recipes keep only the top rows, or they leave out cancelled, written-off or future-dated items. The watch-out notes list the filters that matter for each question.
No. The sample databases are practice data. Use them to learn the patterns, then apply the same patterns to your own records.
More tools: all tools · function reference · guides