Sybase AdaptiveServerEnterpriseに実装する必要のある長いネストされた完全外部結合シーケンスがあります。このための関数を書くことは可能ですか?
以下のコードを簡略化したい:
select t1.col_01, t1.col_02, TOT_Jan, TOT_Feb
from
(select a.col_01, a.col_02, sum(b.col_XX) as TOT_Jan
FROM vw_aux a ...
and year(b.tms_mydate) = 2012
and month(b.tms_mydate) = 1
... ) t1
left outer join
(select a.col_01, a.col_02, sum(b.col_XX) as TOT_Feb
... and year(b.tms_mydate) = 2012
and month(b.tms_mydate) = 2
... ) t2 on t1.col_aux = t2.col_aux
UNION
(select a.col_01, a.col_02, sum(b.col_XX) as TOT_Jan ...) t1
right outer join (select a.col_01, a.col_02, sum(b.col_XX) as TOT_Feb ...) t2
on ...
次のような関数を作成します。
funcion myfullouterjoin (vw_aux, table_01, col_aux, col_01, col_02, tms_mydate, TOT_Jan, TOT_Feb)