SELECT DISTINCT p.ContractID,ch.CompanyID,e.EmployeeID,e.FirstName,e.MiddleInitial,e.LastName,e.SSN,c.FederalTaxID, CONVERT(VARCHAR(10),BeginLastDate.BeginDate,101) AS BeginDate,CONVERT(VARCHAR(10),BeginLastDate.LastDate,101) AS LastDate,CONVERT(VARCHAR(10),ch.EndDate,101) as EndDate FROM CprWeekly cw INNER JOIN CprHeader ch ON cw.CprHeaderID = ch.CprHeaderID ...
ORDER BY e.FirstName,e.LastName,ch.EndDate
这个地方ch.如果不去掉,在我机器上是对的,在server是出错。
错误消息: ORDER BY items must appear in the select list if SELECT DISTINCT is specified.