zoukankan      html  css  js  c++  java
  • oracle的 listagg() WITHIN GROUP () 行转列函数的使用

    参考如下:

    select listagg(reveitemname, ',') within group (order by reveitemname)fdb from 
    (
        select 
        distinct
        gg.projid,
        gg.contractname||
        case 
            when gg.revetype='1'   and   gg.rrighttype='2'    then '房产' 
            when gg.revetype='1'   and   gg.rrighttype='3'    then '土地' 
            when gg.revetype='1'   and   gg.rrighttype='4'    then '设备' 
            when gg.revetype='1'   and   gg.rrighttype='10'   then '汽车' 
            when gg.revetype='1'   and   gg.rrighttype='5'    then '其他物证' 
            when gg.revetype='2'   and   gg.rrighttype='6'    then '股权' 
            when gg.revetype='2'   and   gg.rrighttype='8'    then '其他物权' 
            when gg.revetype='2'   and   gg.rrighttype='18'   then '专利权' 
            when gg.revetype='10'  and   gg.rrighttype='19'   then '浮动抵押' 
            when gg.revetype='11'  and   gg.rrighttype='7'    then '应收账款' 
        end  reveitemname  
        from
        (
            select 
            pci.*,
            (select count(1) from comm_attachment_relation c where c.objectid=pci.contractid  and c.attachmenttype in ('23','29') ) as ishavepactfile ,        
            (
                select max(rrighttype) from CRM_COUNTERGUARANTEE_PRO tt ,guarantyandcontractapprrel ww
                where tt.projid=ww.projid
                and tt.faserialid=ww.faserialid
                and ww.contractid=pci.contractid
            ) as rrighttype,        
            (
                select max(tt.revetype) from CRM_COUNTERGUARANTEE_PRO tt ,guarantyandcontractapprrel ww
                where tt.projid=ww.projid
                and tt.faserialid=ww.faserialid
                and ww.contractid=pci.contractid
            ) as revetype
            from PROJ_CONTRACT_INFO  pci  order by substr(pci.contractcode, 11,15),pci.createtime
        ) gg  
    )where  projid=xxx

     查询结果显示:

    夫妻连带保证-反担保,个人保证-反担保,企业保证-反担保,委托保证合同,质押-反担保股权

    end;

  • 相关阅读:
    ThinkPHP5 API 文档
    【转】移动web页面使用字体的思考
    【原】移动web页面兼容处理的思考
    20140829分享正则大纲
    javascript reverse string
    备忘“与”、“非”、“或”、“异或” 运算
    关于 Apple Metal API 的一些想法
    transform:rotate在手机上显示有锯齿的解决方案
    JS正则表达式验证数字(很全)
    去掉 wap (android/ios)网页等点击后的阴影
  • 原文地址:https://www.cnblogs.com/xh_Blog/p/15088956.html
Copyright © 2011-2022 走看看