how can connect 2 grouped below query?
select [fiscal year],[fiscal quater],sum([colx])as x table1 group [fiscal year],[fiscal quater]; select [fiscal year],[fiscal quater],sum([coly]) y table2 group [fiscal year],[fiscal quater];
result should return column: [fiscal year],[fiscal quater], x, y
you want this:
select coalesce(t1.[fiscal year], t2.[fiscal year]) [fiscal year], coalesce(t1.[fiscal quater], t2.[fiscal quater]) [fiscal quater], coalesce(t1.x, 0) x, coalesce(t2.y, 0) y ( select [fiscal year], [fiscal quater], sum([colx]) x table1 group [fiscal year], [fiscal quater]) t1 full join ( select [fiscal year], [fiscal quater], sum([coly]) y table2 group [fiscal year], [fiscal quater] ) t2 on t1.[fiscal year] = t2.[fiscal year] , t1.[fiscal quater] = t2.[fiscal quater]
Comments
Post a Comment