Lesson 7 of 13 · 26 min
Financial statement extracts: P&L and balance sheet
By the end of this lesson you can extract an income statement (revenue, cost of sales, gross profit, operating expenses, net profit) and a balance sheet at a date from the general ledger, and prove that assets equal liabilities plus equity.
The two main statements answer different questions and are built from different accounts:
| Statement | Accounts | Measures | Time |
|---|---|---|---|
| Profit and loss (P&L, income statement) | revenue (4xxx) and expense (5xxx, 6xxx) | activity over a period | a period, e.g. FY2025 |
| Balance sheet | asset (1xxx), liability (2xxx), equity (3xxx) | balances | a point in time, e.g. 31 Dec 2025 |
The P&L of Tahlia is presented in the classic layout:
Revenue (4100 + 4200 − 4900 sales returns)
− Cost of sales (5xxx)
= Gross profit
− Operating expenses (6xxx)
= Net profitThe parent account groups the lines: 4000 Revenue, 5000 Cost of Sales, 6000 Operating Expenses. Joining gl_accounts to itself on parent_account_code gives each postable account its section name.
This lesson, its 4 graded exercises and every other Members lesson in SQL Quest come with a Formula Quest membership that includes SQL (Single Quest with SQL selected, Quest Trio including SQL, or Quest Unlimited), or with SQL access from your organization.
Free to everyone: all of SQL Foundations and Retrieving and Filtering Data, the first lesson of every track, the playground, the dataset library and the SQL reference. See free lessons