Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
SCHEMA
Posting Yak Master
192 Posts |
Posted - 2012-11-12 : 09:40:17
|
[code]I have Company table which has companyname,Program and ReceivedAmountProgram Account Table is like Lookup Table.It says for which program and for acccount number how much money is allocated. From this table money is distributed based on Program and Accountnumber.[/code]Company ( Main table)CompanyName Program ActualReceivedAmountA P1 140000B P2 136000C P2 76000D P2 220000E P2 52000ProgramAccount ( This is lookup table)Program AccountNumber AccountAmountP1 100011 24000P1 100012 116000P2 100045 180000P2 100046 304000I want to get output like this from above.CompanyName Program AccountNumber ActualReceivedAmountA P1 100011 24000A P1 100012 116000B P2 100046 136000C P2 100046 76000D P2 100045 180000D P2 100046 40000E P2 100046 52000OrCompanyName Program AccountNumber ActualReceivedAmountA P1 100011 24000A P1 100012 116000B P2 100045 136000C P2 100045 44000C P2 100046 32000D P2 100046 220000E P2 100046 52000Or this combinationCompanyName Program AccountNumber ActualReceivedAmountA P1 100011 24000A P1 100012 116000B P2 100045 136000C P2 100046 76000D P2 100046 220000E P2 100046 8000E P2 100045 44000[code]Any Combination is fine. We will not try to split unless it is required. we will try to use as money as possible in that account.We will not try to split unless it is required. we will try to use as money as possible in that account.[/code]Please help. |
|
robvolk
Most Valuable Yak
15732 Posts |
|
SCHEMA
Posting Yak Master
192 Posts |
Posted - 2012-11-12 : 10:26:13
|
Robvolk,This is same question but i have made it simpler than before so it is easy to understand. It was confusing before so I created new one.Please remove the old one.Thanks and I have been trying to break my head but couldn't come up with solution :( |
|
|
|
|
|