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 |
Naqibullah
Starting Member
7 Posts |
Posted - 2015-02-26 : 06:14:45
|
Dear valued colleagues,i have three tables i.e customer, saving, loancustomer to Saving one to many relationshipcustomer to loan one to many relationshipwhen i run query to return total savings and total loan for a specific customer it returns a wrong result although i group by customer.....please help me |
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2015-02-26 : 12:23:53
|
Show us what you have so far, sample data and expected output.Tara KizerSQL Server MVP since 2007http://weblogs.sqlteam.com/tarad/ |
|
|
Naqibullah
Starting Member
7 Posts |
Posted - 2015-03-12 : 01:09:52
|
thanks for your replythis is my querySELECT Group.Group_ID, Group.Group_Name, Sum(MainTbloan.LoanAmount) AS SumOfLoanAmount, Sum(MainTblCredit.FixedSaving) AS SumOfFixedSavingFROM (([Group] INNER JOIN Woman ON Group.Group_ID = Woman.Group_ID) INNER JOIN MainTblCredit ON Woman.Mem_ID = MainTblCredit.MemID) INNER JOIN MainTbloan ON Woman.Mem_ID = MainTbloan.MemIDGROUP BY Group.Group_ID, Group.Group_NameHAVING (((Group.Group_ID)=19)) OR (((Group.Group_ID)=20));This is the result which is a wrong total for SumOfFixedSavingGroup_ID Group Name SumOfLoanAmount SumOfFixedSaving19 Tawfiq 1359990 24809020 Jawidan 119390 21450Grand total 1479380 269540Regards |
|
|
|
|
|