我是ms访问的新手,版本是2005年,当我尝试测试选择查询时它工作它显示所有列名称及其值。
$results = odbc_exec($connection, "SELECT TOP 5 Sequence
,StoreId
,Timestamp
,BusinessDate
,TerminalId
,TerminalName
,DrawerNumber
,TransactionType
FROM [Site5].[dbo].[Transactions]
where [TransactionType] in ('eod','sod') and
businessdate = '2016-12-28' ORDER BY Timestamp asc ");
现在我尝试将TerminalId列值转换为行,但它在这里不起作用是我的代码
$transform = odbc_exec($connection, "
TRANSFORM MAX(Sequence)
SELECT StoreId
FROM Transactions
GROUP BY StoreId
PIVOT TerminalId
");
警告:odbc_exec():SQL错误:[Microsoft] [SQL Server Native Client 10.0] [SQL Server]第2行:“序列”附近的语法错误。,SQL状态37000
答案 0 :(得分:0)
完全限定的表格
NODE_ENV
或
$transform = odbc_exec($connection, "
TRANSFORM MAX(Transactions.Sequence) As Seq
SELECT Transactions.StoreId
FROM Transactions
GROUP BY Transactions.StoreId
PIVOT Transactions.TerminalId
");