-1

以下の要件に対して適切なクエリを作成するにはどうすればよいでしょうか。

employee3列のテーブルがあります

1. Employee ID
2. ManagerID
3. LocationID

最初に返される出力 (1 または 2 または 3 または 4 またはなし) を返したいと思います。追加条件はこちら。

1. EmployeeID = 1233 and ManagerID = 2222 and LocationID = 3333
2. EmployeeID = 1233 and ManagerID is null and LocationID = 3333
3. EmployeeID = 1233 and ManagerID = 2222 and LocationID = 3333
4. EmployeeID = 1233 and ManagerID is null and LocationID is null

このようなロジックが欲しいです。誰でもクエリを取得するのを手伝ってくれますか。

4

4 に答える 4

0

多分これは、あなたの質問からはわかりません

SELECT  * FROM employee
ORDER BY 
CASE WHEN EmployeeID = 1233 and ManagerID = 2222 and LocationID = 3333 THEN 0 ELSE 1 END,
EmployeeID = 1233 and ManagerID is null and LocationID = 3333 THEN 1 ELSE 2 END,
EmployeeID = 1233 and ManagerID = 2222 and LocationID = 3333 THEN 2 ELSE 3 END,
EmployeeID = 1233 and ManagerID is null and LocationID is null THEN 3 ELSE 4 END
于 2013-11-13T21:37:27.817 に答える