TABLE2をSelectした結果のC2フィールドの値で、TABLE1のC1フィールドを更新します。
この時、二つのテーブルをKEYフィールドで連結して、どのレコードを対応付けるかを指定しています。
もしも使えるようなら、このままコピペして、TABLE1、TABLE2、KEY、C1、C2あたりを書き換えて使ってもいいと思います。
select case実行結果は以下の通り
when BIRTHDAY > '19890107' then '平成'
when BIRTHDAY > '19261224' then '昭和'
when BIRTHDAY > '19120729' then '大正'
when BIRTHDAY > '18680124' then '明治'
else '0'
end 年号,
case
when BIRTHDAY > '19890107' then BIRTHDAY - 19880000
when BIRTHDAY > '19261224' then BIRTHDAY - 19250000
when BIRTHDAY > '19120729' then BIRTHDAY - 19110000
when BIRTHDAY > '18680124' then BIRTHDAY - 18670000
end 年月日
from (select '19990123' BIRTHDAY) DUMMY
年号 年月日年号と和暦の年月日を出力する。
---- -----------
平成 110123
(1 行処理されました)
select case実行結果
when BIRTHDAY >= '1989' then '平成'
when BIRTHDAY >= '1926' then '昭和'
when BIRTHDAY >= '1912' then '大正'
when BIRTHDAY >= '1868' then '明治'
else '0'
end 年号,
case
when BIRTHDAY >= '1989' then BIRTHDAY - 1988
when BIRTHDAY >= '1926' then BIRTHDAY - 1925
when BIRTHDAY >= '1912' then BIRTHDAY - 1911
when BIRTHDAY >= '1868' then BIRTHDAY - 1867
end 年
from (select '1999' BIRTHDAY) DUMMY
年号 年この場合12月24日~12月31日のいずれかの日を基準とする場合には正常な結果になるが、それ以外で使うには、上記SQLの数字部分を書き換える必要がある。
---- -----------
平成 11
(1 行処理されました)