如何修复SQL Server上的错误102

时间:2014-04-30 10:53:28

标签: sql sql-server-2008

我在sql中有问题请帮帮我 SQL查询:

SELECT CASE
 WHEN (GROUPING(Staff.FirstName + ' ' + Staff.LastName ) = 1) THEN 'ALL'
  ELSE ISNULL(Staff.FirstName + ' ' + Staff.LastName , 'UNKNOWN') END AS Staff.FirstName + ' ' + Staff.LastName  ,  Count( Patient.PatientUniqueID ) AS CountOfPatientID 
  FROM patient LEFT JOIN 
  ((bInsurance RIGHT JOIN 
  ((Admit LEFT JOIN Staff ON Admit.DoctorRef = Staff.GeneralID) LEFT JOIN bWard ON Admit.WardRef = bWard.WardID) 
  ON bInsurance.InsurID = Admit.InsuranceRef)
   LEFT JOIN (Staff AS Staff_Treat RIGHT JOIN PTreat ON Staff_Treat.GeneralID = PTreat.DoctorRef)
    ON Admit.AdmitID = PTreat.AdmitRef) ON patient.PatientUniqueID = Admit.PatientUniqueRef
   Where (PatientUniqueID IN(
    SELECT Patient.PatientUniqueID
     FROM Staff AS StaffUserInf RIGHT JOIN 
     ((((bWard RIGHT JOIN  (Staff RIGHT JOIN Admit ON Staff.StaffID=Admit.DoctorRef) ON  bWard.WardID=Admit.WardRef)
      LEFT JOIN Staff AS Staff_1 ON  Admit.AssistantRef=Staff_1.StaffID)
       RIGHT JOIN Patient ON  Admit.PatientUniqueRef=Patient.PatientUniqueID)
        LEFT JOIN PTreat ON  Admit.AdmitID=PTreat.AdmitRef)
         ON StaffUserInf.UserName=Admit.CreatedBy  Where  1 = 1 ) ) 
GROUP BY Staff.FirstName + ' ' + Staff.LastName   ;With Cube

错误: Msg 102,Level 15,State 1,Line 3 '附近的语法不正确。'。 Msg 102,Level 15,State 1,Line 17 ')附近的语法不正确

0 个答案:

没有答案