---
title: "ORACLE 的if else"
author: "jslfl"
date: "2012-07-10T17:12:46Z"
tags: ["decode"]
categories: ["数据库"]
slug: "oracle-if-else"
draft: false
lastmod: "2012-07-10T17:12:46Z"
id: 1584415
url: "https://jslfl.iteye.com/blog/1584415"
---

a.
select
(case score when 0 then '无成绩' else '有成绩' end) as score
from table

select
(case score when 0 then '无成绩' when 60 then '好成绩' else '有成绩' end) as score
from table

b.
select
decode(score,0,'无成绩',20,'低成绩',60,'过得去','好成绩') as score
from table

-- 最后的好成绩是默认