I have a table "COAcc" and the following are the data
AccID AccTitle PAccId AccStatus OpenBal
001 Asset Null G 0
002 Liability Null G 0
003 Capital Null G 0
004 Expense Null G 0
005 Revenue Null G 0
001-001 Current Asset 001 G 0
001-001-0001 Cash Account 001-001 L 50000
001-001-0002 Checking Account 001-001 L 25000
001-002 Fixed Asset 001 G 0
001-002-0001 Computers 001-002 L 75000
001-002-0002 Machinery 001-002 L 125000
How a Look at data:
Scennario
Accid 001 is Parent/Group Account and that's why its PAccid is null.
The SubAccounts/Child Accounts of 001 are 001-001 and 001-002 and its Parent Account is 001.
Similarly, SubAccounts/Child Account of 001-001 are 001-001-0001 and 001-001-0002 and its Parent Account is 001-001
I think you understand the Parent/Child relation.
Now I come to point. I want to retreive the data through query like this.
AccID AccTitle PAccId AccStatus OpenBal
001 Asset Null G 275000
001-001 Current Asset 001 G 75000
001-001-0001 Cash Account 001-001 L 50000
001-001-0002 Checking Account 001-001 L 25000
001-002 Fixed Asset 001 G 200000
001-002-0001 Computers 001-002 L 75000
001-002-0002 Machinery 001-002 L 125000
Look at the openbal
Original Data
Accid Paccid OpenBal
001 Null 0
001-001 001 0
001-001-0001 001-001 50000
001-001-0002 001-001 25000
Queried Data
Accid Paccid OpenBal
001 Null 275000 sum of Paccid (001)
001-001 001 75000 sum of Paccid (001-001)
001-001-0001 001-001 50000
001-001-0002 001-001 25000
001-002 001 200000 sum of Paccid (001-002)
001-002-0001 001-002 75000
001-002-0002 001-002 125000
I hope you better understand. Please give me reply as soon as possible.
AccID AccTitle PAccId AccStatus OpenBal
001 Asset Null G 0
002 Liability Null G 0
003 Capital Null G 0
004 Expense Null G 0
005 Revenue Null G 0
001-001 Current Asset 001 G 0
001-001-0001 Cash Account 001-001 L 50000
001-001-0002 Checking Account 001-001 L 25000
001-002 Fixed Asset 001 G 0
001-002-0001 Computers 001-002 L 75000
001-002-0002 Machinery 001-002 L 125000
How a Look at data:
Scennario
Accid 001 is Parent/Group Account and that's why its PAccid is null.
The SubAccounts/Child Accounts of 001 are 001-001 and 001-002 and its Parent Account is 001.
Similarly, SubAccounts/Child Account of 001-001 are 001-001-0001 and 001-001-0002 and its Parent Account is 001-001
I think you understand the Parent/Child relation.
Now I come to point. I want to retreive the data through query like this.
AccID AccTitle PAccId AccStatus OpenBal
001 Asset Null G 275000
001-001 Current Asset 001 G 75000
001-001-0001 Cash Account 001-001 L 50000
001-001-0002 Checking Account 001-001 L 25000
001-002 Fixed Asset 001 G 200000
001-002-0001 Computers 001-002 L 75000
001-002-0002 Machinery 001-002 L 125000
Look at the openbal
Original Data
Accid Paccid OpenBal
001 Null 0
001-001 001 0
001-001-0001 001-001 50000
001-001-0002 001-001 25000
Queried Data
Accid Paccid OpenBal
001 Null 275000 sum of Paccid (001)
001-001 001 75000 sum of Paccid (001-001)
001-001-0001 001-001 50000
001-001-0002 001-001 25000
001-002 001 200000 sum of Paccid (001-002)
001-002-0001 001-002 75000
001-002-0002 001-002 125000
I hope you better understand. Please give me reply as soon as possible.