使用下表 http://i.imgur.com/rIMgFZC.png
检索与Mat David具有相同E_level值且与Mat David在同一商店工作的员工姓名。
SELECT E_fname,E_lname
FROM Employee E,
(SELECT E_Level
FROM Employee E
WHERE UPPER(E.E_lname) = ‘DAVID’
AND UPPER(E.Efname) = ‘MAT’) elevel,
(SELECT E_Store_ID
FROM Employee E
WHERE UPPER(E.E_lname) = ‘DAVID’
AND UPPER(E.Efname) = ‘MAT’
) estoreid
WHERE E.E_level = elevel.E_level
AND E.Store_ID = estoreid.Store_ID
AND UPPER(E.E_lname) != ‘DAVID’
AND UPPER(E.Efname) != ‘MAT’;
SELECT E_fname,E_lname
FROM EMPLOYEE E
WHERE E.E_level =
(SELECT E_level
FROM Employee E
WHERE UPPER(E.E_lname) = ‘DAVID’
AND UPPER(E.Efname) = ‘MAT’)
AND E.E_Store_ID =
(SELECT E_Store_ID
FROM Employee E
WHERE UPPER(E.E_lname) = ‘DAVID’
AND UPPER(E.Efname) = ‘MAT’)
AND UPPER(E.E_lname) != ‘DAVID’
AND UPPER(E.Efname) != ‘MAT’;
这些是我的尝试。我是对的吗?
答案 0 :(得分:0)
SELECT E_fname,E_lname
FROM Employee E
WHERE E_level = (SELECT E_Level
FROM Employee E
WHERE UPPER(E.E_lname) = 'DAVID'
AND UPPER(E.E_fname) = 'MAT')
AND E_store_ID = (SELECT E_Store_ID
FROM Employee E
WHERE UPPER(E.E_lname) = 'DAVID'
AND UPPER(E.E_fname) = 'MAT'
)
AND UPPER(E.E_lname) != 'DAVID'
AND UPPER(E.E_fname) != 'MAT';