I have to design report for printing/viewing chart of account. My chart of account is base on two filed on acc_id (PK) second parent account id
acc_id, ParAccountID Title
1 NULL Assets
1001 1 Fixed Assets
1001001 1001 Computer
1001002 1001 Office Eqipment
1001003 1001 Furniture & Fixture
1002 1 Current Assets
1003 1 Cash & Bank
1004 1 Cash at IOU
2 NULL Equity and Liabilities
2001 2 Current Liabilities
2002 2 Freight Payable
3 NULL Revenue
4 Expense
I want to display them like this:
Code Title
1 Asset
1001 Fixed Assets
1001001 Computer
1001002 Office Equipment
1001003 Furniture & Fixture
2 Equity and Liabilities
2001 Current Liabilities
Is there any one how can guide me in which format it can be display on best way or about MS SQL.
try this :
select acct_id,title from table where paraccountid is null
union all
select acct_id,title from table where paraccountid is not null