·含義解釋
decode(條件
該函數的含義如下
IF 條件=值
RETURN(翻譯值
ELSIF 條件=值
RETURN(翻譯值
ELSIF 條件=值n THEN
RETURN(翻譯值n)
ELSE
RETURN(缺省值)
END IF
·使用方法
select decode(sign(變量
sign()函數根據某個值是
例如
變量
則sign(變量
現有一個商品銷售表sale
month char(
sell number(
現有數據為
想要轉化為以下結構的數據
year char(
month
month
month
month
month
month
month
month
month
month
month
month
結構轉化的SQL語句為
create or replace view
v_sale(year
month
as
select
substrb(month
sum(decode(substrb(month
sum(decode(substrb(month
sum(decode(substrb(month
sum(decode(substrb(month
sum(decode(substrb(month
sum(decode(substrb(month
sum(decode(substrb(month
sum(decode(substrb(month
sum(decode(substrb(month
sum(decode(substrb(month
sum(decode(substrb(month
sum(decode(substrb(month
from sale
group by substrb(month
From:http://tw.wingwit.com/Article/program/Oracle/201311/18599.html