--6找出各系年龄最大的学生,显示其学号、姓名;有错,怎么改才正确,谢谢各位了
--6找出各系年龄最大的学生,显示其学号、姓名;
SELECT sno,sname
FROM S
WHERE sage=
(SELECT MAX(sage)
FROM S
WHERE sdept='CS'
)
UNION
SELECT sno,sname
FROM S
WHERE sage=
(SELECT MAX(sage)
FROM S
WHERE sdept='MA'
)
UNION
SELECT sno,sname
FROM S
WHERE sage=
(SELECT MAX(sage)
FROM S
WHERE sdept='IS'
);
用这种方法查询正确但是较烦琐,以下是我用另一种方法的查询但是结果有错误,大家帮忙改下,谢谢了
/*SELECT sno,sname
FROM S
WHERE sage=
(SELECT MAX(sage)
FROM S
WHERE sdept='CS' OR sdept='IS' OR sdept='MA' );*/结果有错
[此贴子已经被作者于2007-4-22 22:51:29编辑过]