zoukankan      html  css  js  c++  java
  • donetcharting中使用的sql语句

    donetcharting数据返回格式为项目列,数据列1,数据列2.。。。数据列就是条形图中的条和饼形图中的块。

    alter procedure pro_hourshot
    @conditionStart varchar(60),
    @conditionEnd varchar(60)
    as
    if(@conditionStart is not null or @conditionStart !='' or @conditionEnd is not null or @conditionEnd !='')
    
    begin
    
    --使用CTE(共用表表达式)的SQL语句应紧跟在相关的CTE后面,否则失效
    with yuyue as (
    select datepart(hh,dialogTime) as somehour, count(*) as yuyuecount
    from yy_detail where 1=1 and tujing=(select id from yy_tujingtype where name='网络') 
    and (dialogTime between @conditionStart and @conditionEnd)
    convert(varchar(10),dialogTime,120) ='2013-12-15'
    group by datepart(hh,dialogTime) 
    ),daoyuan as(
    select datepart(hh,jizhendate) as somehour, count(*) as daoyuancount
    from yy_detail where 1=1 and tujing=(select id from yy_tujingtype where name='网络') 
    and (jizhendate between @conditionStart and @conditionEnd) 
    -- @daoyuancondition and convert(varchar(10),jizhendate,120) ='2013-12-15'
    group by datepart(hh,jizhendate) 
    )
    
    select 
    --注意使用sum
    result.date,sum(result.aayuyuecount),sum(result.aadaoyuancount) from 
    (
    select fullresult.somehour as date,AAAA.data_yuyuecount as aayuyuecount,AAAA.data_daoyuancount as aadaoyuancount from 
    (
    select datepart(hh,dialogTime) as somehour from yy_detail where convert(varchar(4),dialogTime,120)='2013' group by datepart(hh,dialogTime)
    ) as fullresult
    left join 
    (
    select yuyue.somehour as data_hour , yuyue.yuyuecount as data_yuyuecount,daoyuan.daoyuancount as data_daoyuancount 
    from yuyue 
    left join daoyuan on yuyue.somehour=daoyuan.somehour
    )as AAAA
    on fullresult.somehour=AAAA.data_hour
    
    union
    
    select fullresult.somehour,BBB.data_yuyuecount,BBB.data_daoyuancount from 
    (
    select datepart(hh,dialogTime) as somehour from yy_detail where convert(varchar(4),dialogTime,120)='2013' group by datepart(hh,dialogTime)
    ) as fullresult
    
    left join 
    (
    select daoyuan.somehour as data_hour , yuyue.yuyuecount as data_yuyuecount,daoyuan.daoyuancount as data_daoyuancount
    from daoyuan
    left join yuyue on yuyue.somehour=daoyuan.somehour
    )as BBB
    on fullresult.somehour=BBB.data_hour
    ) as result
    group by result.date
    
     
    
    
    end

    饼形图则为

    select (
    select name from yy_area where id=yy_detail.patientaddress
     ) as area,
    count(*) as count from yy_detail
     where 1=1 and tujing =(select top 1 id from yy_tujingtype where name='网络') group by patientaddress order by count desc
  • 相关阅读:
    tar打包如何不打包某一个文件夹(排除某些文件夹)
    第一个SpringBoot应用
    Linux(以RHEL7为例)下添加工作区的方法|| The Way To Add Workspace On Linux
    Linux(以centos7为例)下自动挂载NTFS硬盘
    基于Moodle的IT课程辅助教育平台搭建
    搭建基于python +opencv+Beautifulsoup+Neurolab机器学习平台
    如何利用word2013写图文并茂的博客
    如何安装win10+Red Hat Enterprise Linux双系统?
    课堂练习:ex 4-20
    实验二 函数重载、函数模板、简单类的定义和实现
  • 原文地址:https://www.cnblogs.com/wanglao/p/3538807.html
Copyright © 2011-2022 走看看