zoukankan      html  css  js  c++  java
  • ORACLE 数据库函数使用

    <![CDATA[
                  select usr.userid userid, decode(count(ba.account_number), '0', ' ', LISTAGG(ba.account_number,',') within group(order by usr.userid, usr.firstname, usr.lastname, ar.name, sp.lock_reason, sp.status)) accountnumber,
                  NVL(usr.firstname, ' ') firstname, NVL(usr.lastname, ' ') lastname, ar.name userrole,
                  NVL(sp.lock_reason, decode(sp.status,1,'global.label.lockoutReason.accountExpired','')) reason, 'global.label.reactivate' action
                  from edx_bsl_umf_user usr, edx_bsl_auth_secprofile sp, edx_bsl_sec_prof_roles_link prl, edx_bsl_auth_secrole ar,
                  edx_umf_user_acct_link ual, edx_omf_account ba
                  where usr.userid = sp.userid and sp.profileid = prl.profile_id and prl.role_id = ar.id
                  and (sp.islocked = 1 or (sp.status=1 and to_date('$reportContext.getCurrentDateTime()','mm/dd/yyyy hh24:mi:ss') > sp.DATE_PASSWD_EXP)) and usr.isactive = 1 and ar.type = 'B2C'
                  and usr.userid = ual.userid and ual.account_key = ba.account_key and ba.deletedat is null
                  group by usr.userid, usr.firstname, usr.lastname, ar.name, sp.lock_reason, sp.status
                  union
                  select usr.userid userid, decode(count(osa.account_number), '0', ' ', LISTAGG(osa.account_number,',') within group(order by usr.userid, usr.firstname, usr.lastname, ar.name, sp.lock_reason, sp.status)) accountnumber,
                  NVL(usr.firstname, ' ') firstname, NVL(usr.lastname, ' ') lastname, ar.name userrole,
                  NVL(sp.lock_reason, decode(sp.status,1,'global.label.lockoutReason.accountExpired','')) reason, 'global.label.reactivate' action
                  from edx_bsl_umf_user usr, edx_bsl_auth_secprofile sp, edx_bsl_sec_prof_roles_link prl, edx_bsl_auth_secrole ar,
                  user_service_agreement usa, edx_omf_serviceagreement osa
                  where usr.userid = sp.userid and sp.profileid = prl.profile_id and prl.role_id = ar.id
                  and (sp.islocked = 1 or (sp.status=1 and to_date('$reportContext.getCurrentDateTime()','mm/dd/yyyy hh24:mi:ss') > sp.DATE_PASSWD_EXP)) and usr.isactive = 1 and ar.type = 'B2B'
                  and usr.userid = usa.userid(+) and usa.service_agreement_id = osa.service_key(+)
                  and osa.delete_date is null
                  group by usr.userid, usr.firstname, usr.lastname, ar.name, sp.lock_reason, sp.status
                ]]>

    decode:相当于 if else

    nvl(args1,args2):当args=null返回,args2

    listagg():

    测试数据
    SQL> 
    SQL> select empno,ename,deptno from scott.emp;

    EMPNO ENAME DEPTNO
    ----- ---------- ------
    7369 SMITH 20
    7499 ALLEN 30
    7521 WARD 30
    7566 JONES 20
    7654 MARTIN 30
    7698 BLAKE 30
    7782 CLARK 10
    7788 SCOTT 20
    7839 KING 10
    7844 TURNER 30
    7876 ADAMS 20
    7900 JAMES 30
    7902 FORD 20
    7934 MILLER 10

    SQL> SELECT deptno,
            LISTAGG(ename, ',') WITHIN GROUP(ORDER BY ename) AS employees
            FROM scott.emp
            GROUP BY deptno;

    DEPTNO EMPLOYEES
    ------ --------------------------------------------------------------------------------
    10 CLARK,KING,MILLER
    20 ADAMS,FORD,JONES,SCOTT,SMITH
    30 ALLEN,BLAKE,JAMES,MARTIN,TURNER,WARD

  • 相关阅读:
    4 weekend110的textinputformat对切片规划的源码分析 + 倒排索引的mr实现 + 多个job在同一个main方法中提交
    3 weekend110的shuffle机制 + mr程序的组件全貌
    2 weekend110的hadoop的自定义排序实现 + mr程序中自定义分组的实现
    1 weekend110的复习 + hadoop中的序列化机制 + 流量求和mr程序开发
    weekend110(Hadoop)的 第四天笔记
    4 weekend110的YARN的通用性意义 + yarn的job提交流程
    3 weekend110的job提交的逻辑及YARN框架的技术机制 + MR程序的几种提交运行模式
    Caused by: java.lang.ClassNotFoundException: org.objectweb.asm.ClassVisitor
    Android SDK 和 Eclipse ADT 离线安装 教程
    leetcode——Evaluate Reverse Polish Notation 求算式值(AC)
  • 原文地址:https://www.cnblogs.com/bb3q/p/5129596.html
Copyright © 2011-2022 走看看