Oracle SQL CASE COMPLEX複雜用法教學
使用工具sqldeveloper
請先參考 sqldeveloper下載及安裝及連線
測試資料來源請先參考 Oracle DB 目錄
關鍵詞(keyword): case
複雜 case
case where 來源 條件 什麼值 then 是的輸出值
where 來源 條件 什麼值 then 是的輸出值
else 否的輸出值
end "別名"
例:
使用employees
薪水收入等次
低收入 0~4999
中低收入 5000~9999
中收入 10000~14999
中高收入 15000~ 19999
高收入 20000以上
SELECT
employee_id,
salary,
case when salary between 0 and 4999 then '低收入'
when salary between 5000 and 9999 then '中低收入'
when salary between 10000 and 14999 then '中收入'
when salary between 15000 and 19999 then '中高收入'
else '高收入'
end "薪水收入等次"
FROM employees
WHERE employee_id > 140
order by salary;
測試:
- 首頁
- JAVA 目錄
- JAVA WEB 目錄
- JAVA 其他未分類 目錄
- Grails目錄
- jQuery 目錄
- Apache 目錄
- JavaScript 目錄
- Spring + Hibernate 目錄
- Hibernate 目錄
- Linux 目錄
- 程式開發工具目錄
- MySQL 目錄
- PHP目錄
- C/C++ 目錄
- Google App Engine 目錄
- HTML5/CSS3
- 程式開發基本資訊
- Android
- Oracle 目錄
- Struts 目錄