★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関数については、
次回ご紹介します。
プログラムみたいに条件処理ができます。
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関数については、
次回ご紹介します。
PR
INDEX
- Mysql ハードディスク故障時 データデース 抜き取りの方法
- SQL TO_NUMBER関数
- SQL CONCAT関数 SQLのCONCAT関数について
- SQL ALTER SQLのALTERとは
- SQL SUM関数 合計値
- SQL AVG関数 平均値
- sql コマンド ネスト 関数 使用
- sql コマンド COALESCE関数 NULL値 処理
- sql コマンド NULLIF関数 null値 処理
- sql コマンド NVL関数 null値 処理
- sql コマンド case decode関数 使用
- sql コマンド DISTINCT SELECT 重複行 削除
- sql コマンド group by グループ化
- postgres sql 部分インデックス
- sql コマンド データ 並び替えORDER BY
- sql help テーブル 列 別名 as
- create テーブル作成
- postgres ログイン 方法 データベース接続 方法
- select as 別名
- select 問い合わせ postgres ①
