Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Finance Balance Sheet creation using SQL

Apps_DeveloperSep 4 2023

Hi

I am trying to generate finance balance sheet output using sql query. I can create subtotal using "grouping by", but I am struggling to find how to subtract subtotals for Income and Expense to generate net income.

Below is code for creation of sample data
create table accounts
(
account_type varchar2(40)
,account_subtype varchar2(40)
,account_hierarchy number
,account_parent number
,account_number number
,amount number
);

insert into accounts values ('Income' ,'Interest' ,9999,1000 ,1001 ,5000 );
insert into accounts values ('Income' ,'Previous Year Rollover' ,9999,1000 ,1002 ,15000 );
insert into accounts values ('Income' ,'Current Year Income' ,9999,1000 ,1003 ,25000 );
insert into accounts values ('Expense' ,'Employees Salary' ,9999,2000 ,2001 ,15000 );
insert into accounts values ('Expense' ,'Employees Superannuations' ,9999,2000 ,2002 ,3000 );
insert into accounts values ('Expense' ,'Vehicle Expenses' ,9999,3000 ,3001 ,5000 );
insert into accounts values ('Expense' ,'Travel Expenses' ,9999,3000 ,3002 ,2000 );

I need to generate data in below format

This post has been answered by Frank Kulash on Sep 4 2023
Jump to Answer
Comments
Post Details
Added on Sep 4 2023
4 comments
662 views