{$page}
Explanation of SQL
This SQL (Report) can be used to pull the Balance Sheet for any period in an easy-to-export format.
Note: The Retained Earnings balance is not pulled into this report. The retained earnings amount calculation is shown in a separate SQL below, but is not included as a row in the report
Sample Export
| RowID | FormattedName | Balance | |||
| 1 | Assets | NULL | |||
| 2 | > Undeposited Funds | NULL | |||
| 1 | » Undeposited Cash & Checks | ||||
| 1 | » Undeposited AmEx | 800.00 | |||
| 1 | » Undeposited Visa_MC | 1024.00 | |||
| 1 | > Inventory Assets | NULL | |||
Risk of Data Corruption if Run Improperly
None. This is a selection query and no data is modified in the running of it.
SQL
DECLARE @GLDate datetime;
DECLARE @ShowZero bit;
DECLARE @ShowInactive bit;
–SET @GLDate ;
–SET @ShowZero ;
–SET @ShowInActive ;
SET @GLDate '12/31/2009 23:59';
SET @ShowZero 1;
SET @ShowInactive 0;
DECLARE @Spacing int;
SET @Spacing 4;
SELECT *
FROM
(
SELECT
ROW_NUMBER() OVER(ORDER BY FormattedPath) as Row,
GLTree.FormattedName,
coalesce((select sum(Amount) from GL where GL.GLAccountID GLTree.NodeID and EntryDateTime