|
TRANSFORM 语句示例
此示例使用 SQL TRANSFORM 子句创建交叉表查询显示 1994 年每一季每位员工所接的订单的数目。 该 SQLTRANSFORMOutput 函数对此过程的完成是必须的。
SubSub()
Dim dbs As Database
Dim strSQL As String
Dim qdfTRANSFORM As QueryDef
strSQL = "PARAMETERS prmYear SHORT; TRANSFORM " _
& "Count(OrderID) " _
& "SELECT FirstName & "" "" & LastName AS " _
& "FullName FROM Employees INNER JOIN Orders " _
& "ON Employees.EmployeeID = " _
& "Orders.EmployeeID WHERE DatePart" _
& "(""yyyy"", OrderDate) = [prmYear] "
strSQL = strSQL & "GROUP BY FirstName & " _
& """ "" & LastName " _
& "ORDER BY FirstName & "" "" & LastName " _
& "PIVOT DatePart(""q"", OrderDate)"
' 在您的计算机中修改此行使其正确指到 Northwind 的路径。
Set dbs = OpenDatabase("Northwind.mdb")
' 对运费超过 $100 的订单,
Set qdfTRANSFORM = dbs.CreateQueryDef _
("", strSQL)
SQLTRANSFORMOutput qdfTRANSFORM, 1994
dbs.Close
End Sub
此示例使用 SQL TRANSFORM 子句创 |
|