zoukankan      html  css  js  c++  java
  • Pro_[计数据分析] 存储过程

    USE [420900_2012]
    GO
    /****** Object:  StoredProcedure [dbo].[计数据分析]    Script Date: 08/28/2012 09:31:55 ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO


    ALTER PROCEDURE [dbo].[计数据分析]
    @CheckTimeStar varchar(12),--时间段
    @CheckTimeEnd varchar(12)--时间段
    AS
    declare @SqlStr varchar(5000)
    declare @SqlZFY varchar(1000)--总费用
    declare @SqlZFYHj varchar(1000)--总费用合计
    declare @SqlZFYFHj varchar(1000)--非基药费用合计
    declare @SqlXm varchar(1000)--项目费用合计
    BEGIN


    set @SqlZFY='select a.orgcode,  sum(a.fee)合计 from o_CbZyBxDjzb a,o_CbZyBxDj b,o_CbZyZdb c
    where  WriteDate >='''+@CheckTimeStar+''' and WriteDate <='''+@CheckTimeEnd+''' and c.billcode=b.billcode and c.billno=b.billno
     and a.orgcode=b.orgcode and a.coopmedcode=b.coopmedcode and a.idno=b.idno and a.diagno=b.diagno'
     
    set @SqlZFYHj=@SqlZFY+ ' group by  a.orgcode'
     
    set @SqlZFYFHj=@SqlZFY+' FeeTypeCode in (''000204'',''000102'',''000202'')group by  a.orgcode'

    set @SqlXm=@SqlZFY+' FeeTypeCode  not in (''000204'',''000102'',''000202'') and WipeOut =''2'') group by  a.orgcode'

    set @SqlStr= 'select a.* ,b.非基药比例,c.项目比例 诊疗项目费 from
    (select a.orgcode ,a.HospitalName, sum(totalfee)/count(1)例均住院费用,sum(DayCount )/count(1)平均住院天数,(sum(totalfee)/count(1))/(sum(DayCount )/count(1))平均床日费用
    from dbo.o_CbZyBxDj a ,  o_CbZyZdb b
    where a.orgcode in (select orgcode from p_ylfwdw where OrgType =2)
    and  WriteDate >='''+@CheckTimeStar+''' and WriteDate <='''+@CheckTimeStar+'''
    and a.billcode=b.billcode and a.billno=b.billno
    group by a.orgcode,a.HospitalName)a ,
    (select a.orgcode,b.合计/a.合计 非基药比例 from
    ('+@SqlZFYFHj+')a,('+@SqlZFYFHj+')b where a.orgcode=b.orgcode
    )b,(select a.orgcode,b.合计/a.合计 项目比例 from
    ('+@SqlZFYFHj+')a,('+@SqlXm+')b
     where a.orgcode=b.orgcode)c
     where a.orgcode=b.orgcode and a.orgcode=c.orgcode'
    print @SqlStr
    exec(@SqlStr)
    END

  • 相关阅读:
    Dictionary-Guided Editing Networks for Paraphrase Generation解读
    CGMH:Constrained Sentence Generation by Metropolis-Hastings Sampling解读
    Text Infilling解读
    K-MEANS算法
    SVM-支持向量机算法
    003-文本分析
    002-贝叶斯拼写纠正实例
    001-贝叶斯算法简介
    【矩阵的乘积/复合变换】- 图解线性代数 05
    【行列式】- 图解线性代数 04
  • 原文地址:https://www.cnblogs.com/520cc/p/2735872.html
Copyright © 2011-2022 走看看