2014-03-05 164 views
1

我有一個關於如何根據員工性別找到工資歧視的問題。我有MS Acess 2007,必須使用SQL查詢算出它如何對多個查詢中的多個列進行排序?

請記住,這是我將3個表合併成一個多表查詢之後。在此查詢,每當我想與排序任何列,例如,ORDER BY Salary,它給了我一個錯誤牌子,上面寫着:

Syntax error (missing operator) in query expression 'Salary' 
WHERE JobClass.JobClassID = Employees.JobClassID 
AND Department.DepartmentID = Employees.DepartmentID'. 

我想嘗試排序的查詢中多列。

下面是多表查詢代碼總數:

SELECT JobClass.JobClassID, JobClassName, Department.DepartmentID, 
     DepartmentName, LastName, FirstName, Title, Sex, Years, Salary 
FROM JobClass, Employees, Department 
ORDER BY 'Salary' 
WHERE JobClass.JobClassID = Employees.JobClassID AND Department.DepartmentID = Employees.DepartmentID; 
+0

'爲了by'後應' where條款 –

+0

並從訂單B中刪除'' Y'薪水' –

回答

0

除非訪問'07完全忽視標準的SQL(我不認爲它),你的SQL語法是關閉的。

而是把ORDER BYWHERE條款,應該的WHERE後去

+0

恩,在SQL中沒有'WHILE'子句。 – Yawar

+0

哦,對不起,在哪裏。咄。 –

1

ORDER BY子句應該來的where子句

後嘗試這樣

SELECT JobClass.JobClassID, JobClassName, Department.DepartmentID, 
     DepartmentName, LastName, FirstName, Title, Sex, Years, Salary 
FROM JobClass, Employees, Department 
WHERE JobClass.JobClassID = Employees.JobClassID AND Department.DepartmentID = Employees.DepartmentID 
ORDER BY Salary 

SLECT語法

SELECT [predicate] { * | table.* | [table.]field1 [AS alias1] [, [table.]field2 [AS alias2] [, …]]}  
FROM tableexpression [, …] [IN externaldatabase]  
[WHERE… ]  
[GROUP BY… ]  
[HAVING… ]  
[ORDER BY… ]  
[WITH OWNERACCESS OPTION] 
相關問題