Oracle函数
-- EXTRACT()函数:返回具体的年、月、日、时、分、秒等具体时间。 SELECT EXTRACT (YEAR FROM --SYSDATE SYSTIMESTAMP ) YEAR FROM DUAL; SELECT EXTRACT (MONTH FROM --SYSDATE SYSTIMESTAMP ) YEAR FROM DUAL; SELECT EXTRACT (DAY FROM --SYSDATE SYSTIMESTAMP ) YEAR FROM DUAL; SELECT EXTRACT (HOUR FROM SYSTIMESTAMP) YEAR FROM DUAL; SELECT EXTRACT (MINUTE FROM SYSTIMESTAMP) YEAR FROM DUAL; SELECT EXTRACT (SECOND FROM SYSTIMESTAMP) YEAR FROM DUAL; SELECT EXTRACT (DAY FROM SYSTIMESTAMP) YEAR FROM DUAL; SELECT EXTRACT(YEAR FROM ORDERDATE) AS O --EG: SELECT EXTRACT(YEAR FROM SYSDATE) AS YEAR_, EXTRACT(MONTH FROM SYSDATE) AS MONTH_, EXTRACT(DAY FROM SYSDATE) AS DAY_ FROM DUAL
--NVL(EXPR1,EXPR2)
--如果EXPR1不为空则返回EXPR1,否则返回EXPR2。
--NVL2(EXPR1,EXPR2)
--如果EXPR1不为空,返回EXPR2,否则返回EXPR3。
--说明:NVL()函数中的两个表达式的类型可以是:数字型,字符型,日期型。 --但必须是相同的类型,否则要对其进行类型转换。NVL(TO_CHAR(COLUMN_NAME),TO_CHAR(COLUMN_NAME) --EG: SELECT NVL([COLUMN_NAME]),TO_CHAR([COLUMN_NAME])) FROM [TABLE_NAME];
--DECODE(EXPR1,IF1,VALUE1,IF2,VALUE2,IF3,VALUE3,VALUE4) --DECODE()函数中如果EXPR1=IF1 RETURN VALUE1,ELSE EXPR1=IF2 RETURN VALUE2,ELSE EXPR1=IF3 RETURN VALUE3 --如果出现基数且EXPR1与所有的IF都不想等则直接返回基数列的值。 --EG:SELECT DECODE([COLUMN_NAME],'1','是','2','否','3','进行中','已结束') FROM [TABLE_NAME];