コメント |
@DIV
select
case
when 年月日1 is NULL and 年月日2 is NULL then 年月日3
when 年月日2 is NULL and 年月日3 is NULL then 年月日1
when 年月日1 is NULL and 年月日3 is NULL then 年月日2
when 年月日1 is NULL and 年月日2 <= 年月日3 then 年月日3
when 年月日1 is NULL and 年月日2 > 年月日3 then 年月日2
when 年月日2 is NULL and 年月日1 <= 年月日3 then 年月日3
when 年月日2 is NULL and 年月日1 > 年月日3 then 年月日1
when 年月日3 is NULL and 年月日1 <= 年月日2 then 年月日2
when 年月日3 is NULL and 年月日1 > 年月日2 then 年月日1
when 年月日1 <= 年月日2 and 年月日3 <= 年月日2 then 年月日2
when 年月日2 <= 年月日1 and 年月日3 <= 年月日1 then 年月日1
when 年月日1 <= 年月日3 and 年月日2 <= 年月日3 then 年月日3
else 年月日1
end as 最終年月日
, 年月日1
, 年月日2
, 年月日3
from テーブル
@END
|