oracle一些常用函数用法
来源:互联网 发布:网络规划设计师教材 编辑:程序博客网 时间:2024/06/05 00:39
出自 http://www.iteye.com/topic/602339
SUBSTR(string,start,count)
取子字符串,从start开始,取count个
SQL> select substr('13088888888',3,8) sub from dual;
SUB
--------
08888888
UPPER
返回字符串,并将所有的字符大写
SQL> select upper('AaBbCcDd') upper from dual;
UPPER
--------
AABBCCDD
LOWER
返回字符串,并将所有的字符小写
SQL> select lower('AaBbCcDd')AaBbCcDd from dual;
AABBCCDD
--------
aabbccdd
FLOOR
对给定的数字取整数
SQL> select floor(2345.67) fl from dual;
FL
--------------
2345
ROUND
按照指定的精度进行舍入
SQL> select round(55.5) roA,round(-55.4) roB from dual;
ROA ROB
----------- ------------
56 -55
SIGN
取数字n的符号,大于0返回1,小于0返回-1,等于0返回0
SQL> select sign(123) A,sign(-100) B,sign(0) C from dual;
A B C
--------- ---------- ---------
1 -1 0
.ADD_MONTHS
增加或减去月份
SQL> select to_char(add_months(to_date('199912','yyyymm'),2),'yyyymm') A from dual;
A
------
200002
SQL> select to_char(add_months(to_date('199912','yyyymm'),-2),'yyyymm') A from dual;
A
------
199910
SYSDATE
用来得到系统的当前日期
SQL> select to_char(sysdate,'dd-mm-yyyy day') A from dual;
A
-----------------09-05-2004 星期日
TO_CHAR(date,'format')
SQL> select to_char(sysdate,'yyyy/mm/dd hh24:mi:ss') A from dual;
A
-------------------
2004/05/09 21:14:41
TO_NUMBER
将给出的字符转换为数字
SQL> select to_number('1999') year from dual;
YEAR
---------
1999
AVG(DISTINCT|ALL)
all表示对所有的值求平均值,distinct只对不同的值求平均值
SQLWKS> create table table3(xm varchar(8),sal number(7,2));
语句已处理。
SQLWKS> insert into table3 values('gao',1111.11);
SQLWKS> insert into table3 values('gao',1111.11);
SQLWKS> insert into table3 values('zhu',5555.55);
SQLWKS> commit;
SQL> select avg(distinct sal) A from gao.table3;
A
----------------
3333.33
SQL> select avg(all sal) from gao.table3;
A
-----------
2592.59
GROUP BY
主要用来对一组数进行统计
SQL> select deptno,count(*) ,sum(sal) from scott.emp group by deptno;
DEPTNO COUNT(*) SUM(SAL)
--------- --------- ---------
10 3 8750
20 5 10875
30 6 9400
HAVING
对分组统计再加限制条件
SQL> select deptno,count(*),sum(sal) from scott.emp group by deptno having count(*)>=5;
DEPTNO COUNT(*) SUM(SAL)
--------- --------- ---------
20 5 10875
30 6 9400
SQL> select deptno,count(*),sum(sal) from scott.emp having count(*)>=5 group by deptno ;
DEPTNO COUNT(*) SUM(SAL)
--------- --------- ---------
20 5 10875
30 6 9400
ORDER BY
用于对查询到的结果进行排序输出
SQL> select deptno,ename,sal from scott.emp order by deptno,sal desc;
DEPTNO ENAME SAL
--------- ---------- ---------
10 KING 5000
10 CLARK 2450
10 MILLER 1300
20 SCOTT 3000
20 FORD 3000
20 JONES 2975
20 ADAMS 1100
20 SMITH 800
30 BLAKE 2850
30 ALLEN 1600
30 TURNER 1500
30 WARD 1250
30 MARTIN 1250
30 JAMES 950
- oracle一些常用函数用法
- oracle一些常用函数
- Oracle 一些常用函数
- Oracle 一些常用函数的用法(收集)
- Oracle的一些常用函数
- oracle中一些常用函数
- oracle的一些常用函数。。。。。。。。。。。。
- oracle 一些常用的函数
- Oracle 常用的一些函数
- Oracle中一些常用函数
- Oracle 常用函数的用法
- string的一些常用函数用法
- string类一些常用函数用法
- oracle 中一些独特的函数用法
- Oracle instr()函数的一些特殊用法
- oracle一些高级函数的用法
- oracle中,一些独有的函数用法
- Oracle常用的一些时间处理函数
- Linux常用文件操作命令
- logger.isDebugEnabled()的作用
- zStack 扩展开发流程-zstack-java部分
- python-正则表达式 匹配多个字符串的语法规则
- BOOST 线程完全攻略 - 基础篇 .
- oracle一些常用函数用法
- Android四大动画详解
- File操作 - list()/listFiles()
- exlipse第一次如何导入JAVA项目,并运行
- gridview的属性
- gexf
- Hadoop之MapReduce快速入门
- Android TabLayout使用以及自定义TabLayout的item
- JAVA从数据库中拿到数据