我有以下用 Access 2003 编写的 SQL。现在,我必须使用 SQL Server2008 开发 prj,并在 SQL Server2008 上运行此 SQL 时出现错误,因为 Access 的 First() 函数无法在 SQL Server 2008 中识别。在 SQL Server 2008 年,我尝试了 TOP() 函数,但我仍然无法解决它。请帮我。
SELECT DISTINCTROW TableA.TCode,
TableA.DCode,
TableA.DepCode,
TableA.ShouhinCode,
First(TableB.TName) AS TNameFirstRecord,
First(TableC.LDepName) AS LDepNameFirstRecord,
First(TableD.ThingType) AS ThingTypeFirstRecord,
First(TableA.GoodsName) AS GoodsNameFirstRecord,
Sum(TableA.Amount) AS AmountData,
Sum(TableA.MoneyAmount) AS MoneyAmountData,
Sum(TableA.DetailedMoneyAmount) AS DetailedMoneyAmounData,
Sum(TableA.SummaryMoneyAmount) AS SummaryMoneyAmountData,
TableA.POSNo
FROM (
(TableA INNER JOIN TableC ON TableA.DCode = TableC.DCode)
INNER JOIN TableB ON TableA.TCode = TableB.TCode
)
INNER JOIN TableD ON TableA.DepCode = TableD.DepCode
GROUP BY TableA.TCode,
TableA.DCode,
TableA.DepCode,
TableA.ShouhinCode,
TableA.POSNo
ORDER BY TableA.TCode,
TableA.DCode,
TableA.DepCode,
TableA.ShouhinCode