ソース掲示板




すべてから検索

キーワード   条件 表示 現行ログ 過去ログ トピックス 名前 本文
同一行中の複数列を一番大きい値の列として独立させる ( No.1 )
日時: 2007/08/24 13:03
名前: lightbox



拡張子:
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 テーブル