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:

StatementAccountsMeasuresTime
Profit and loss (P&L, income statement)revenue (4xxx) and expense (5xxx, 6xxx)activity over a perioda period, e.g. FY2025
Balance sheetasset (1xxx), liability (2xxx), equity (3xxx)balancesa 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 profit

The 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.

Included with a Formula Quest membership

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