Task
FinSight Analytics stores normalized financial statement line items in a single table. A common first step in analysis is summarizing statement values by statement type.
Write a SQL query to calculate the total amount for each statement_type for company Apex Retail in fiscal year 2023.
Requirements
- Filter to rows where
company_name = 'Apex Retail' and fiscal_year = 2023
- Return
statement_type and the summed amount as total_amount
- Order the result by
total_amount in descending order
Table Definition
| column_name | type | description |
|---|
| id | INT | Unique row identifier |
| company_name | VARCHAR(100) | Company name |
| statement_type | VARCHAR(50) | Financial statement category such as Income Statement or Balance Sheet |
| line_item | VARCHAR(100) | Specific metric name |
| fiscal_year | INT | Reporting year |
| amount | DECIMAL(14,2) | Reported amount |
Sample Data
| id | company_name | statement_type | line_item | fiscal_year | amount |
|---|
| 1 | Apex Retail | Income Statement | Revenue | 2023 | 1250000.00 |
| 2 | Apex Retail | Income Statement | Operating Expense | 2023 | -420000.00 |
| 3 | Apex Retail | Balance Sheet | Cash | 2023 | 180000.00 |
| 4 | Apex Retail | Cash Flow Statement | Operating Cash Flow | 2023 | 210000.00 |
| 5 | Beacon Health | Income Statement | Revenue | 2023 | 980000.00 |
| 6 | Apex Retail | Income Statement | Net Income | 2022 | 95000.00 |
Expected Output
| statement_type | total_amount |
|---|
| Income Statement | 740000.00 |
| Cash Flow Statement | 210000.00 |
| Balance Sheet | 150000.00 |