1

我有这个代码:

SELECT TransactionDate, CustomerName, TreatmentName, Price
FROM MsCustomer mc, HeaderSalonServices hss,DetailSalonServices dss, MsTreatment mt, MsStaff ms
WHERE mc.CustomerId = hss.CustomerId AND hss.StaffId = ms.StaffId
AND hss.TransactionId=dss.TransactionId and dss.TreatmentId=mt.TreatmentId
AND StaffName LIKE 'Ryan%' and DATENAME(WEEKDAY, TransactionDate)='thursday'
ORDER BY CustomerName, TreatmentName
COMPUTE SUM(price) BY CustomerName

它不会运行,并且一直说“'COMPUTE'附近的语法不正确”我做错了什么?

这是我的 ERD:

ERD

4

2 回答 2

0

COMPUTE / COMPUTE BY 在 SQL 2012 中停止使用。http://msdn.microsoft.com/en-us/library/ms144262.aspx 而不是 COMPUTE / COMPUTE BY 使用ROLLUP

于 2013-04-14T15:44:48.977 回答
0

执行以下操作,您将获得计算结果:

Select columnname, count(*) From tablename Group by columnname Order by columnname Select 'SUM' , COUNT(columnname) from tablename

于 2015-08-14T20:39:04.533 回答