sql语句由浅入深

1、decode函数:decode(条件,值1,翻译值1,值2,翻译值2,...值n,翻译值n,缺省值)

举例:select monthid , decode (sale,1000,'D',2000,'C',3000,'B',4000,'A',’Other’) sale from output

2、nvl函数

3、sign函数:根据某个值是0、正数还是负数,分别返回0、1、-1

举例:select monthid,decode(sign(sale-6000),-1,sale,6000) from output,即达到取较小值的目的。

猜你喜欢

转载自happytech.iteye.com/blog/1717728