C#里select语句实现表格绑定到chart中,但是想将x轴变成1月,2月,3月。,就是现在这张图的列名,然后对应的第一行的值为曲线一的Y轴,第二行为曲线二的Y轴的值,求大神告知如何将chart的X轴绑定为数据源的列名,Y轴绑定为行,或者怎么将这个表改成第一列为月份,内容为1月到12月,第二列为曲线1的对应月份的值,第二列为对应曲线2的值
现在的代码是 SELECT t1.1a as 1月,t1.2a as 2月,t1.3a as 3月,t1.4a as 4月,t1.5a as 5月,t1.6a as 6月,t1.7a as 7月,t1.8a as 8月,t1.9a as 9月,t1.10a as 10月,t1.11a as 11月,t1.12a as 12月
from(select detection_item_name a0,count(case when (`galaxy_detection_record`.`detection_date` >= '2015/01/01 0:00:00' and galaxy_detection_record.detection_date <= '2015/01/31 23:59:59') then 1 else NULL end) AS 1a,
count(case when (`galaxy_detection_record`.`detection_date` >= '2015/02/01 0:00:00' and `galaxy_detection_record`.`detection_date` <= '2015/02/31 23:59:59') then 1 else NULL end) AS 2a,
count(case when (`galaxy_detection_record`.`detection_date` >= '2015/03/01 0:00:00' and `galaxy_detection_record`.`detection_date` <= '2015/03/31 23:59:59') then 1 else NULL end) AS 3a,
count(case when (`galaxy_detection_record`.`detection_date` >= '2015/04/01 0:00:00' and `galaxy_detection_record`.`detection_date` <= '2015/04/31 23:59:59') then 1 else NULL end) AS 4a,
count(case when (`galaxy_detection_record`.`detection_date` >= '2015/05/01 0:00:00' and `galaxy_detection_record`.`detection_date` <= '2015/05/31 23:59:59') then 1 else NULL end) AS 5a,
count(case when (`galaxy_detection_record`.`detection_date` >= '2015/06/01 0:00:00' and `galaxy_detection_record`.`detection_date` <= '2015/06/31 23:59:59') then 1 else NULL end) AS 6a,
count(case when (`galaxy_detection_record`.`detection_date` >= '2015/07/01 0:00:00' and `galaxy_detection_record`.`detection_date` <= '2015/07/31 23:59:59') then 1 else NULL end) AS 7a,
count(case when (`galaxy_detection_record`.`detection_date` >= '2015/08/01 0:00:00' and `galaxy_detection_record`.`detection_date` <= '2015/08/31 23:59:59') then 1 else NULL end) AS 8a,
count(case when (`galaxy_detection_record`.`detection_date` >= '2015/09/01 0:00:00' and `galaxy_detection_record`.`detection_date` <= '2015/09/31 23:59:59') then 1 else NULL end) AS 9a,
count(case when (`galaxy_detection_record`.`detection_date` >= '2015/10/01 0:00:00' and `galaxy_detection_record`.`detection_date` <= '2015/10/31 23:59:59') then 1 else NULL end) AS 10a,
count(case when (`galaxy_detection_record`.`detection_date` >= '2015/11/01 0:00:00' and `galaxy_detection_record`.`detection_date` <= '2015/11/31 23:59:59') then 1 else NULL end) AS 11a,
count(case when (`galaxy_detection_record`.`detection_date` >= '2015/12/01 0:00:00' and `galaxy_detection_record`.`detection_date` <= '2015/12/31 23:59:59') then 1 else NULL end) AS 12a from galaxy_detection_record GROUP BY detection_item_name ) t1 UNION SELECT sum(1a),sum(2a),sum(3a),sum(4a),sum(5a),sum(6a),sum(7a),sum(8a),sum(9a),sum(10a),sum(11a),sum(12a) from(select detection_item_name a0,count(case when (`galaxy_detection_record`.`detection_date` >= '2015/01/01 0:00:00' and galaxy_detection_record.detection_date <= '2015/01/31 23:59:59') then 1 else NULL end) AS 1a,count(case when (`galaxy_detection_record`.`detection_date` >= '2015/02/01 0:00:00' and `galaxy_detection_record`.`detection_date` <= '2015/02/31 23:59:59') then 1 else NULL end) AS 2a,count(case when (`galaxy_detection_record`.`detection_date` >= '2015/03/01 0:00:00' and `galaxy_detection_record`.`detection_date` <= '2015/03/31 23:59:59') then 1 else NULL end) AS 3a,count(case when (`galaxy_detection_record`.`detection_date` >= '2015/04/01 0:00:00' and `galaxy_detection_record`.`detection_date` <= '2015/04/31 23:59:59') then 1 else NULL end) AS 4a,count(case when (`galaxy_detection_record`.`detection_date` >= '2015/05/01 0:00:00' and `galaxy_detection_record`.`detection_date` <= '2015/05/31 23:59:59') then 1 else NULL end) AS 5a,count(case when (`galaxy_detection_record`.`detection_date` >= '2015/06/01 0:00:00' and `galaxy_detection_record`.`detection_date` <= '2015/06/31 23:59:59') then 1 else NULL end) AS 6a,count(case when (`galaxy_detection_record`.`detection_date` >= '2015/07/01 0:00:00' and `galaxy_detection_record`.`detection_date` <= '2015/07/31 23:59:59') then 1 else NULL end) AS 7a,count(case when (`galaxy_detection_record`.`detection_date` >= '2015/08/01 0:00:00' and `galaxy_detection_record`.`detection_date` <= '2015/08/31 23:59:59') then 1 else NULL end) AS 8a,count(case when (`galaxy_detection_record`.`detection_date` >= '2015/09/01 0:00:00' and `galaxy_detection_record`.`detection_date` <= '2015/09/31 23:59:59') then 1 else NULL end) AS 9a,count(case when (`galaxy_detection_record`.`detection_date` >= '2015/10/01 0:00:00' and `galaxy_detection_record`.`detection_date` <= '2015/10/31 23:59:59') then 1 else NULL end) AS 10a,count(case when (`galaxy_detection_record`.`detection_date` >= '2015/11/01 0:00:00' and `galaxy_detection_record`.`detection_date` <= '2015/11/31 23:59:59') then 1 else NULL end) AS 11a,count(case when (`galaxy_detection_record`.`detection_date` >= '2015/12/01 0:00:00' and `galaxy_detection_record`.`detection_date` <= '2015/12/31 23:59:59') then 1 else NULL end) AS 12a from galaxy_detection_record GROUP BY detection_item_name ) t1
现在的代码是 SELECT t1.1a as 1月,t1.2a as 2月,t1.3a as 3月,t1.4a as 4月,t1.5a as 5月,t1.6a as 6月,t1.7a as 7月,t1.8a as 8月,t1.9a as 9月,t1.10a as 10月,t1.11a as 11月,t1.12a as 12月
from(select detection_item_name a0,count(case when (`galaxy_detection_record`.`detection_date` >= '2015/01/01 0:00:00' and galaxy_detection_record.detection_date <= '2015/01/31 23:59:59') then 1 else NULL end) AS 1a,
count(case when (`galaxy_detection_record`.`detection_date` >= '2015/02/01 0:00:00' and `galaxy_detection_record`.`detection_date` <= '2015/02/31 23:59:59') then 1 else NULL end) AS 2a,
count(case when (`galaxy_detection_record`.`detection_date` >= '2015/03/01 0:00:00' and `galaxy_detection_record`.`detection_date` <= '2015/03/31 23:59:59') then 1 else NULL end) AS 3a,
count(case when (`galaxy_detection_record`.`detection_date` >= '2015/04/01 0:00:00' and `galaxy_detection_record`.`detection_date` <= '2015/04/31 23:59:59') then 1 else NULL end) AS 4a,
count(case when (`galaxy_detection_record`.`detection_date` >= '2015/05/01 0:00:00' and `galaxy_detection_record`.`detection_date` <= '2015/05/31 23:59:59') then 1 else NULL end) AS 5a,
count(case when (`galaxy_detection_record`.`detection_date` >= '2015/06/01 0:00:00' and `galaxy_detection_record`.`detection_date` <= '2015/06/31 23:59:59') then 1 else NULL end) AS 6a,
count(case when (`galaxy_detection_record`.`detection_date` >= '2015/07/01 0:00:00' and `galaxy_detection_record`.`detection_date` <= '2015/07/31 23:59:59') then 1 else NULL end) AS 7a,
count(case when (`galaxy_detection_record`.`detection_date` >= '2015/08/01 0:00:00' and `galaxy_detection_record`.`detection_date` <= '2015/08/31 23:59:59') then 1 else NULL end) AS 8a,
count(case when (`galaxy_detection_record`.`detection_date` >= '2015/09/01 0:00:00' and `galaxy_detection_record`.`detection_date` <= '2015/09/31 23:59:59') then 1 else NULL end) AS 9a,
count(case when (`galaxy_detection_record`.`detection_date` >= '2015/10/01 0:00:00' and `galaxy_detection_record`.`detection_date` <= '2015/10/31 23:59:59') then 1 else NULL end) AS 10a,
count(case when (`galaxy_detection_record`.`detection_date` >= '2015/11/01 0:00:00' and `galaxy_detection_record`.`detection_date` <= '2015/11/31 23:59:59') then 1 else NULL end) AS 11a,
count(case when (`galaxy_detection_record`.`detection_date` >= '2015/12/01 0:00:00' and `galaxy_detection_record`.`detection_date` <= '2015/12/31 23:59:59') then 1 else NULL end) AS 12a from galaxy_detection_record GROUP BY detection_item_name ) t1 UNION SELECT sum(1a),sum(2a),sum(3a),sum(4a),sum(5a),sum(6a),sum(7a),sum(8a),sum(9a),sum(10a),sum(11a),sum(12a) from(select detection_item_name a0,count(case when (`galaxy_detection_record`.`detection_date` >= '2015/01/01 0:00:00' and galaxy_detection_record.detection_date <= '2015/01/31 23:59:59') then 1 else NULL end) AS 1a,count(case when (`galaxy_detection_record`.`detection_date` >= '2015/02/01 0:00:00' and `galaxy_detection_record`.`detection_date` <= '2015/02/31 23:59:59') then 1 else NULL end) AS 2a,count(case when (`galaxy_detection_record`.`detection_date` >= '2015/03/01 0:00:00' and `galaxy_detection_record`.`detection_date` <= '2015/03/31 23:59:59') then 1 else NULL end) AS 3a,count(case when (`galaxy_detection_record`.`detection_date` >= '2015/04/01 0:00:00' and `galaxy_detection_record`.`detection_date` <= '2015/04/31 23:59:59') then 1 else NULL end) AS 4a,count(case when (`galaxy_detection_record`.`detection_date` >= '2015/05/01 0:00:00' and `galaxy_detection_record`.`detection_date` <= '2015/05/31 23:59:59') then 1 else NULL end) AS 5a,count(case when (`galaxy_detection_record`.`detection_date` >= '2015/06/01 0:00:00' and `galaxy_detection_record`.`detection_date` <= '2015/06/31 23:59:59') then 1 else NULL end) AS 6a,count(case when (`galaxy_detection_record`.`detection_date` >= '2015/07/01 0:00:00' and `galaxy_detection_record`.`detection_date` <= '2015/07/31 23:59:59') then 1 else NULL end) AS 7a,count(case when (`galaxy_detection_record`.`detection_date` >= '2015/08/01 0:00:00' and `galaxy_detection_record`.`detection_date` <= '2015/08/31 23:59:59') then 1 else NULL end) AS 8a,count(case when (`galaxy_detection_record`.`detection_date` >= '2015/09/01 0:00:00' and `galaxy_detection_record`.`detection_date` <= '2015/09/31 23:59:59') then 1 else NULL end) AS 9a,count(case when (`galaxy_detection_record`.`detection_date` >= '2015/10/01 0:00:00' and `galaxy_detection_record`.`detection_date` <= '2015/10/31 23:59:59') then 1 else NULL end) AS 10a,count(case when (`galaxy_detection_record`.`detection_date` >= '2015/11/01 0:00:00' and `galaxy_detection_record`.`detection_date` <= '2015/11/31 23:59:59') then 1 else NULL end) AS 11a,count(case when (`galaxy_detection_record`.`detection_date` >= '2015/12/01 0:00:00' and `galaxy_detection_record`.`detection_date` <= '2015/12/31 23:59:59') then 1 else NULL end) AS 12a from galaxy_detection_record GROUP BY detection_item_name ) t1
解决方案 »
- 修改数剧库问题!求教
- 最近研究了一下sqlserver的全文索引,发现了一个重大问题
- 请问怎样把远程xml文档写入sql数据库?
- 用友面试题。TMD他是不是耍我?
- 急!!大家帮帮忙!!image字段转换text为什么汉字是乱码啊?如何将image字段转换为ntext?
- 能否创建像系统函数一样用法的自定义函数?
- 一个表中要用2个字段组合成 主键 ,怎样在定义表时定义这样的主键,怎样把这样的主键定义成外键?
- 怎么知道函数调用的次数?
- 在写存储过程中有没有分隔函数?
- 请大家推荐一些讲存储过程的文档
- update A = 多行数据 where B = 多行数据
- 如何同时统计本日,本月,本年以及同期,与同期比数据
unpivot
(
数值 for 列名 in (
[1月], [2月], [3月], [1月],
[5月], [6月], [7月], [8月],
[9月], [10月], [11月], [12月])
) as T