我是 Excel VBA 的死忠粉,不得不过渡到一个非常基本的基于 SQL 的软件。我已经设法使现有查询适应我的需求(仍然不确定如何!)但我可以通过一些帮助来进一步调整它:)
查询是:
PARAMETERS [Date From] DateTime, [Date To] DateTime, [Site Group] Text;
SELECT Contacts.Name, DataProfile.Date, DataProfile.TotalUnits
FROM (Lookup INNER JOIN Groups ON Lookup.Lookup_Id = Groups.Lookup_Id) INNER JOIN (Contacts INNER JOIN (Points INNER JOIN DataProfile ON Points.Id = DataProfile.Point_Id) ON Contacts.Id = Points.Contacts_Id) ON Groups.Link_Id = Contacts.Id
WHERE (((Lookup.Lookup_Name)=[Site Group]) AND ((DataProfile.Date) Between [Date From] And [Date To]) AND ((Points.Type)='Electricity') AND ((DataProfile.Type)=0))
AND Contacts.Group_1=[Client Group]
ORDER BY Contacts.Name, DataProfile.Date;
这会按站点按天生成每日总计列表,如下所示:
站点.......日期............值
站点 1....01/01/13...444.7
站点 1....02/01/13...861.5
站点1....03/01/13...850.0
等...
是否可以将查询写入输出为:
站点.....01/01/13....02/01/13....03/01/13站点1
....444.7.......861.5....... ..850.0
站点2....111.1.......222.2....333.3
等......
每个站点有一排而不是那么多,这将使我的生活变得容易得多。目前我正在编写 excel 代码以适应数据 - 但它很长而且效率不高。如果我能让 SQL 以这种格式输出,我会像某种办公室之神!!!
欢迎任何帮助/建议/指导:)