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
  • 相关阅读:
    Linux安装Memcached服务
    [Shell]随机数
    配置VNC
    Linux挂在ntfs格式的U盘
    大数据入门第五天——离线计算之hadoop(上)概述与集群安装
    Hexo+Github博客搭建
    大数据入门第四天——基础部分之轻量级RPC框架的开发
    大数据入门第三天——基础补充与ActiveMQ
    大数据入门第二天——基础部分之zookeeper(下)
    PowerDesigner安装与使用教程
  • 原文地址:https://www.cnblogs.com/wanglao/p/3538807.html
Copyright © 2011-2022 走看看