【发布时间】:2011-03-29 08:40:21
【问题描述】:
问题:
我有从数据库中检索到的数据,如下所示:
现在我需要将其转换为以下格式,以便能够绘制饼图。
在 ReportingService 中,有 Matrix 控件来实现这一点,但是在普通 C# 中我可以使用什么来实现相同的功能,以便将其呈现为 PieChart 图像?
请注意,建筑物的数量以及使用类型是可变的,并且无法提前知道。
编辑:
感谢 Magnus 和 Google 解决:
SELECT * FROM
(
SELECT
STE_Designation AS RPT_Site
,BDG_Designation AS RPT_Building
,UG_Code AS RPT_Usage_Code
,UG_Caption AS RPT_Usage
,SUM(MP_RMArea_Area) AS RPT_Area
FROM V_RPT_RoomDetail
WHERE (RM_MDT_ID = 1)
GROUP BY
STE_Designation
,BDG_Designation
,UG_Code
,UG_Caption
--ORDER BY STE_Designation, BDG_Designation, UG_Code, UG_Caption
) AS SourceTable
PIVOT
(
SUM(RPT_Area)
FOR RPT_Building IN ([Building1], [Building2], [BuildingN])
) AS PivotTable
ORDER BY RPT_Site, RPT_Usage_Code
需要通过 select distinct 在代码中生成数据透视列的位置。
【问题讨论】:
标签: c# .net vb.net datatable charts