1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42:
| select feld01, feld02, feld03, min(feld04) as feld04, min(feld05) as feld05, cast(sum(feld06), currency) as feld06, cast(sum(feld07), currency) as feld07, cast((sum(feld06) - sum(feld07)), currency) as feld08 from select t1.feld01 as feld01, t1.feld02 as feld02, t1.feld03 as feld03, min(t1.feld04) as feld04, min(t1.feld05) as feld05, cast(sum(t1.feld09), currency) as feld06, cast(0.0, currency) as feld07 from tabelle01 as t1 where t1.feld01 = 'konstante01' and t1.feld02 <> 'konstante01' group by feld01, feld02, feld03
union
select t1.feld01 as feld01, t1.feld02 as feld02, t1.feld03 as feld03, min(t1.feld04) as feld04, min(t1.feld05) as feld05, cast(0.0, currency) as feld06, cast(case when sum(t2.feld09) is null then 0.0 else sum(t2.feld09) end, currency) as feld07 from tabelle01 as t1 full outer join tabelle02 as t2 using (feld01, feld03) where t1.feld01 = 'konstante01' and t1.feld02 <> 'konstante01' group by feld01, feld02, feld03
where feld01 = 'konstante01' and feld02 <> 'konstante01'
group by feld01, feld02, feld03 order by feld01, feld02, feld03 |