SQL: a consolidated balance sheet

Wm wm+gnc at tarrcity.demon.co.uk
Sat Jan 10 23:56:19 EST 2015


Sat, 10 Jan 2015 14:25:44 <YUcT4QIoZTsUFwYE at tarrcity.demon.co.uk>  Wm
<wm+gnc at tarrcity.demon.co.uk>

>Sun, 28 Dec 2014 10:30:25 <rstfmEQBv9nUFwkM at tarrcity.demon.co.uk>  Wm
><wm+gnc at tarrcity.demon.co.uk>
>
>[ff to self, ongoing SQL tutorial of sorts]

[again]

>>this is a gnucash balance sheet that should work with any SQL backend
>
>>===
>>Select
>>  Sum(splits.value_num),
>>  accounts.account_type
>>From
>>  splits Inner Join
>>  accounts On accounts.guid = splits.account_guid
>>Group By
>>  accounts.account_type
>>Having
>>  accounts.account_type Not In ('EXPENSE', 'INCOME')
>>Order By
>>  accounts.account_type
>>===
>>
>>that, people, is a balance sheet, the rest is presentation.

I appear to have neglected to show the CoA I presented earlier in use as
a sensible balance sheet.

===
Select
  Sum(splits.value_num / splits.value_denom) As V,
  coa.account_type,
  coa.name_tabs,
  coa.name_tree
From
  coa Inner Join
  splits On splits.account_guid = coa.guid
Group By
  coa.account_type, coa.name_tabs, coa.name_tree
Order By
  coa.account_type
===

should do as an intermediate step for now.

-- 
Wm...


More information about the gnucash-user mailing list