sql server instructions help 入門 sponsored link


sql コマンド case decode関数 使用

★SQL★ の中で、

プログラムみたいに条件処理ができます。

Oracleにおいては、
ifのほかに
case式と
decode関数があります。

decode関数はOracleの関数です。


select コード,身長,体重,
case 体重 when 50 then '50kg'
                  when 60 then '60kg'
                  when 90 then '90kg まぁ 太ってる'
                 when 100 then ' 100kg 太ってるよ!'
                 when 150 then '150kg でか!'
                when 200 then '200kg 太りすぎ!'
                else 'もう一度'
end as 感想
from 測定テーブル;

select  コード,商品名,値段
case when 値段 <= 500 then ''安い!'
          when 値段 <=1000 then  '高め'
        when 値段 <=2000 then '高すぎ!'
end as 感想
from 天丼価格テーブル;


decode関数については、
次回ご紹介します。



sql server instructions help 入門 sponsored link





Buzzurl/ hatena/ MyYahoo!/ livedoorClip/ Google/ niftyclip/ pookmark/ flog/ FC2/

category

SQL


<<select>>
banner_14.gif

<<SQL>>
banner_14.gif

<<sql distinct>>
banner_14.gif

ブログランキング