oracle 函数

1、并操作嵌套查询(属于集合A和集合B的元素的总和)
(select deptno from scott.emp)
union
  (select deptno from scott.dept);
2、交操作查询(属于集合A且集合B的元素的总和)
(select deptno from scott.emp)
 intersect
  (select deptno from scott.dept);
3、差操作查询(属于集合A且不属于集合B的元素的总和)
(select deptno from scott.emp)
 minus
  (select deptno from scott.dept);
4、ceil函数
     ceil(n),取大于等于数值n的最小整数
      select mgr,mgr/100,ceil(mgr/100) from scott.emp;
5、floor函数
      floor(n),取小于等于数值n的最大整数
      select mgr,mgr/100,floor(mgr/100) from scott.emp;
6、mod函数
       mod(m,n) 去m整除n后的余数。
       select mgr,mod(mgr,1000),mod(mgr,100),mod(mgr,10) from scott.emp;
7、 power函数
        power(m,n)取m的n次方。
        select mgr,power(mgr,2),power(mgr,3) from scott.emp;
8、 round函数
         round(m,n)四舍五入,保留n位。
         select mgr,round(mgr/100,2),round(mgr/1000,2) from scott.emp;
9、 sign函数
       sign(n), n>0,取1;  n=0,取0;   n<0,取-1.
       select mgr,mgr-7800,sign(mgr-7800) from scott.emp;
10、 avg函数
        avg(字段名),求平均值。要求字段为数值型。
        select avg(mgr) 平均薪水 from scott.emp;
11、 count函数
        count(字段名)或 count(*),统计总数。
        select count(*)from scott.emp;
        select count(distinct job) 工作类别总数 from scott.emp;
12、 min函数
        min(字段名),计算数值型字段最小数。
        select min(sal) 最少薪水 from scott.emp;
13、 max函数
         max(字段名),计算数值型字段最大数。
        select max(sal) 最高薪水 from scott.emp;
14、 sum函数
         sum(字段名), 计算数值型字段总和。
         select sum(sal) 薪水总和 from scott.emp;


      
posted @ 2009-07-08 17:07  scott_zhou  阅读(537)  评论(0编辑  收藏  举报