Author: dibyendumandal11111
Subject: Reply to: Join of more than one table
Posted: Tue Feb 14, 2017 10:47 pm (GMT 5.5)
Dear Rohit,
How can you say SUM will be same for both the queries?... Second one have an extra inner join.
Anyway with some help I am able to get the desired result.
Consolidated query is like-
Any better option is still welcome.
coded
Subject: Reply to: Join of more than one table
Posted: Tue Feb 14, 2017 10:47 pm (GMT 5.5)
Dear Rohit,
How can you say SUM will be same for both the queries?... Second one have an extra inner join.
Anyway with some help I am able to get the desired result.
Consolidated query is like-
Code: |
Select T1.ColXX,Sum1,Sum2 from ( (Select TableA.Col1 as ColXX,Sum(TableC.col2) As Sum1 From TableA Inner join TableB on TableA.Colx = TableB.ColY Inner join TableC on TableB.Colx = TableC.ColY group by TableA.Col1 ) as T1 inner join (Select TableA.Col1 as ColXX,Sum(TableC.col2) Sum2 From TableA Inner join TableB on TableA.Colx = TableB.ColY Inner join TableC on TableB.Colx = TableC.ColY Inner join TableD on TableC.Colx = TableD.ColY group by TableA.Col1 ) as T2 on T1.ColXx= T2.ColXX) |
Any better option is still welcome.
coded