manusatsangi
8th August 2003, 15:31
Hi,
We have encountered a requirement from our client where we have to take data from two tables in the same SQL query parallely... something which the UNION clause of SQL.
To define the problem more, suppose I have the following two tables:
1) Loan disbursement details
Fields: Employee id(pk), Loan Id(pk), Disbursement Date(pk), Amount
2) Loan Repayment details
Fields: Employee id(pk), Loan id(pk), Repayment Date(pk), Amount.
Now, an employee can be disbursed a loan on multiple dates and the employee can return back the loan on multiple dates.
NOw if I want to write an SQL query which should scan both the tables parallely and get an output chronologically as per the transactions on a loan. Something like a "loan register".
Now, as I think this could be solved if BaaN SQL had UNION kind of thing. Had there been a summary table which could have contained a combined transactions of both the tables, it would have been easy. But, I do not want to create anotehr table replicating the data of these two tables.
Does anyone have an idea how to solve this?
Thanks & Regards
Manu
We have encountered a requirement from our client where we have to take data from two tables in the same SQL query parallely... something which the UNION clause of SQL.
To define the problem more, suppose I have the following two tables:
1) Loan disbursement details
Fields: Employee id(pk), Loan Id(pk), Disbursement Date(pk), Amount
2) Loan Repayment details
Fields: Employee id(pk), Loan id(pk), Repayment Date(pk), Amount.
Now, an employee can be disbursed a loan on multiple dates and the employee can return back the loan on multiple dates.
NOw if I want to write an SQL query which should scan both the tables parallely and get an output chronologically as per the transactions on a loan. Something like a "loan register".
Now, as I think this could be solved if BaaN SQL had UNION kind of thing. Had there been a summary table which could have contained a combined transactions of both the tables, it would have been easy. But, I do not want to create anotehr table replicating the data of these two tables.
Does anyone have an idea how to solve this?
Thanks & Regards
Manu