网站导航网学 原创论文 原创专题 网站设计 最新系统 原创论文 论文降重 发表论文 论文发表 UI设计定制 论文答辩PPT格式排版 期刊发表 论文专题
返回网学首页
网学原创论文
最新论文 推荐专题 热门论文 论文专题
当前位置: 网学 > 交易代码 > SQL语法 > 正文

SQL统计月

论文降重修改服务、格式排版等 获取论文 论文降重及排版 论文发表 相关服务

【网学网提醒】:网学会员鉴于大家对十分关注,论文会员在此为大家搜集整理了“SQL统计月”一文,供大家参考学习


    SELECT
     BMAS收费单位编码,
     MCAS收费单位名称,
     xmbmAS项目编码,
     xmmcAS项目名称,
    hjAS合计,
    m1AS一月,
    m2AS二月,
    m3AS三月,
    m4AS四月,
    m5AS五月,
    m6AS六月,
    m7AS七月,
    m8AS八月,
    m9AS九月,
    m10AS十月,
    m11AS十一月,
    m12AS十二月
    FROM
     (
     SELECT
     x3.agencycodeASBM,
     x3.agencynameASMC,
     x5.nontaxcodeASxmbm,
     x5.nontaxnameASxmmc,
    sum(amt)AShj,
    CASEWHENstrftime('%m',X1.tradedate)='01'THENsum(X2.AMT)ENDASm1,
     CASEWHENstrftime('%m',X1.tradedate)='02'THENsum(X2.AMT)ENDASm2,
     CASEWHENstrftime('%m',X1.tradedate)='03'THENsum(X2.AMT)ENDASm3,
     CASEWHENstrftime('%m',X1.tradedate)='04'THENsum(X2.AMT)ENDASm4,
     CASEWHENstrftime('%m',X1.tradedate)='05'THENsum(X2.AMT)ENDASm5,
     CASEWHENstrftime('%m',X1.tradedate)='06'THENsum(X2.AMT)ENDASm6,
     CASEWHENstrftime('%m',X1.tradedate)='07'THENsum(X2.AMT)ENDASm7,
     CASEWHENstrftime('%m',X1.tradedate)='08'THENsum(X2.AMT)ENDASm8,
     CASEWHENstrftime('%m',X1.tradedate)='09'THENsum(X2.AMT)ENDASm9,
     CASEWHENstrftime('%m',X1.tradedate)='10'THENsum(X2.AMT)ENDASm10,
     CASEWHENstrftime('%m',X1.tradedate)='11'THENsum(X2.AMT)ENDASm11,
     CASEWHENstrftime('%m',X1.tradedate)='12'THENsum(X2.AMT)ENDASm12
     FROM
     COL_TRADEX1
     LEFTJOINCOL_TRADE_DETAILX2ONx1.guid=x2.tradeid
     INNERJOINBAS_ChargeAgencyX3ONX1.agencyid=X3.guid
     INNERJOINBAS_ChargeProjectX5ONx2.proid=x5.guid
     INNERJOINBAS_RemittedBankX6ONx1.bankid=x6.guid
     INNERJOINBAS_CHGAGENCY2CHGPROT11ONT11.CHARGEAGENCYID=x1.agencyid
     ANDT11.CHARGEPROJECTID=x2.proid
     INNERJOINBAS_RemittedBankT13ONx1.bankid=T13.Guid
     LEFTJOINbas_fundtypefeONx5.fundtypeguid=fe.Guid
     LEFTJOINbas_chargetypectONx5.chargetypeguid=ct.guid
     WHERE
     1=1
     ANDx1.charged='1'
     ANDx1.audited='1'
     ANDx3.agencycodeLIKE'%'
     ANDx5.nontaxcodeLIKE'%'
     ANDx1.CHARGEDATE>='2012-02-1700:00:00'
     ANDx1.CHARGEDATE<='2012-02-1723:59:59'
     ANDX2.NUMLIKE'%'
     ANDX2.AmtLIKE'%'
     ANDCASE
     WHENx3.agencycodeISNULLTHEN
     ''
     ELSE
     x3.agencycode
     ENDLIKE'%'
     ANDCASE
     WHENfe.FUNDTYPECODEISNULLTHEN
     ''
     ELSE
     fe.FUNDTYPECODE
     ENDLIKE'%'
     ANDCASE
     WHENct.chargetypecodeISNULLTHEN
     ''
     ELSE
     ct.chargetypecode
     ENDLIKE'%'
     GROUPBY
     x3.agencycode,
     x3.agencyname,
     x5.nontaxcode,
     x5.nontaxname,
     x6.bankcode,
     x6.bankname
    UNIONALL
    SELECT
     x3.agencycodeASBM,
     x3.agencynameASMC,
     ''ASxmbm,
     '单位小计'ASxmmc,
    sum(amt)AShj,
    CASEWHENstrftime('%m',X1.tradedate)='01'THENsum(X2.AMT)ENDASm1,
     CASEWHENstrftime('%m',X1.tradedate)='02'THENsum(X2.AMT)ENDASm2,
     CASEWHENstrftime('%m',X1.tradedate)='03'THENsum(X2.
    AMT)ENDASm3,
     CASEWHENstrftime('%m',X1.tradedate)='04'THENsum(X2.AMT)ENDASm4,
     CASEWHENstrftime('%m',X1.tradedate)='05'THENsum(X2.AMT)ENDASm5,
     CASEWHENstrftime('%m',X1.tradedate)='06'THENsum(X2.AMT)ENDASm6,
     CASEWHENstrftime('%m',X1.tradedate)='07'THENsum(X2.AMT)ENDASm7,
     CASEWHENstrftime('%m',X1.tradedate)='08'THENsum(X2.AMT)ENDASm8,
     CASEWHENstrftime('%m',X1.tradedate)='09'THENsum(X2.AMT)ENDASm9,
     CASEWHENstrftime('%m',X1.tradedate)='10'THENsum(X2.AMT)ENDASm10,
     CASEWHENstrftime('%m',X1.tradedate)='11'THENsum(X2.AMT)ENDASm11,
     CASEWHENstrftime('%m',X1.tradedate)='12'THENsum(X2.AMT)ENDASm12
     FROM
     COL_TRADEX1
     LEFTJOINCOL_TRADE_DETAILX2ONx1.guid=x2.tradeid
     INNERJOINBAS_ChargeAgencyX3ONX1.agencyid=X3.guid
     INNERJOINBAS_ChargeProjectX5ONx2.proid=x5.guid
     INNERJOINBAS_RemittedBankX6ONx1.bankid=x6.guid
     INNERJOINBAS_CHGAGENCY2CHGPROT11ONT11.CHARGEAGENCYID=x1.agencyid
     ANDT11.CHARGEPROJECTID=x2.proid
     INNERJOINBAS_RemittedBankT13ONx1.bankid=T13.Guid
     LEFTJOINbas_fundtypefeONx5.fundtypeguid=fe.Guid
     LEFTJOINbas_chargetypectONx5.chargetypeguid=ct.guid
     WHERE
     1=1
     ANDx1.charged='1'
     ANDx1.audited='1'
     ANDx3.agencycodeLIKE'%'
     ANDx5.nontaxcodeLIKE'%'
     ANDx1.CHARGEDATE>='2012-02-1700:00:00'
     ANDx1.CHARGEDATE<='2012-02-1723:59:59'
     ANDX2.NUMLIKE'%'
     ANDX2.AmtLIKE'%'
     ANDCASE
     WHENx3.agencycodeISNULLTHEN
     ''
     ELSE
     x3.agencycode
     ENDLIKE'%'
     ANDCASE
     WHENfe.FUNDTYPECODEISNULLTHEN
     ''
     ELSE
     fe.FUNDTYPECODE
     ENDLIKE'%'
     ANDCASE
     WHENct.chargetypecodeISNULLTHEN
     ''
     ELSE
     ct.chargetypecode
     ENDLIKE'%'
     GROUPBY
     x3.agencycode,
     x3.agencyname,
     x5.nontaxcode,
     x5.nontaxname,
     x6.bankcode,
     x6.bankname
     )
    WHERE
     1=1
    ORDERBY
     BM,
     xmbm
    
  • 上一篇资讯: SQL考试
  • 下一篇资讯: sql经典技巧
  • 设为首页 | 加入收藏 | 网学首页 | 原创论文 | 计算机原创
    版权所有 网学网 [Myeducs.cn] 您电脑的分辨率是 像素
    Copyright 2008-2020 myeducs.Cn www.myeducs.Cn All Rights Reserved 湘ICP备09003080号 常年法律顾问:王律师