这是我在某个公司应聘时碰到的考题,列在下面供路过的看看。会的请帮忙留下参考答案,以供大家学习 -- 1、求:比自己所在部门经理的薪水高的员工信息?
NAME SALARY MANAGER DEPT
---------- ------------ ---------- -----
SUPER 1000.00 10
SMITH 800.00 SUPER 10
HAG 1250.00 SUPER 10
FORD 2500.00 20
TOM 2600.00 FORD 20
JARRY 1499.00 FORD 20
-- 2、库存表中,显示如下数据结果
FID FGOODID SCOUNT FTYPE
--- ------- ------ -----
1 1 10 进
1 2 20 进
1 3 20 出
1 1 45 出
1 2 30 进
1 3 40 出
编号 进库 出库 库存
---------- ---------- ---------- ----------
1 10 45 -35
2 50 0 50
3 0 60 -60 -- 3、有下表:
create table t_score(
stuid varchar2(10), (学号)
kc varchar2(50), (课程)
score number(5, 2) (成绩)
)
取每科成绩前两名的学生信息并按课程号和成绩排序(注:使用一条语句)
-- 4、有下表:(t_stu)
FID FNAME SCORE
----- ---------- --------
1 AA 80
2 BB 90
3 CC 95
4 DD 70
5 EE 83
6 FF 66
用一条语句输出,成绩在90分以上评为'EXCELLENT',80-90分评为'GOOD',其他评为'NICE'
NAME SALARY MANAGER DEPT
---------- ------------ ---------- -----
SUPER 1000.00 10
SMITH 800.00 SUPER 10
HAG 1250.00 SUPER 10
FORD 2500.00 20
TOM 2600.00 FORD 20
JARRY 1499.00 FORD 20
-- 2、库存表中,显示如下数据结果
FID FGOODID SCOUNT FTYPE
--- ------- ------ -----
1 1 10 进
1 2 20 进
1 3 20 出
1 1 45 出
1 2 30 进
1 3 40 出
编号 进库 出库 库存
---------- ---------- ---------- ----------
1 10 45 -35
2 50 0 50
3 0 60 -60 -- 3、有下表:
create table t_score(
stuid varchar2(10), (学号)
kc varchar2(50), (课程)
score number(5, 2) (成绩)
)
取每科成绩前两名的学生信息并按课程号和成绩排序(注:使用一条语句)
-- 4、有下表:(t_stu)
FID FNAME SCORE
----- ---------- --------
1 AA 80
2 BB 90
3 CC 95
4 DD 70
5 EE 83
6 FF 66
用一条语句输出,成绩在90分以上评为'EXCELLENT',80-90分评为'GOOD',其他评为'NICE'
(select g.fgood_id as 货物种类,sum(decode(g.ftype,'进',g.scount,0)) as 进库,
sum(decode(g.ftype,'出',g.scount,0)) as 出库
from goods g
group by g.fgood_id) a
where a.salary>(
select salary from S b
where b.manager is null and a.dept=b.dept)
select * from
(
select empno,ename,rownum rn from emp e where exists
(
select ename,rownum rn from
(select deptno from emp where empno=7369) a
where a.deptno = e.deptno
) order by sal desc
)
where rn<=1;第二题:
select gfoodid 编号,
max(decode(ftype,'进',scount,0)) 进,
max(decode(ftype,'出',scount,0)) 出,
max(decode(ftype,'进',scount,0)) -max(decode(ftype,'出',scount,0)) 库存
from kc
group by gfoodid;
第三题:
select * from
(
select stuid, kc, row_number() over(partition by kc order by score desc) rn ,score
from t_score
) where rn<=2;第四题:select fid,fname ,
case when score>90 then 'EXCELLENT'
when score >=80 and score <=90 then 'GOOD'
else 'NICE' end
from t_stu;自己写的,写的不好,希望大家指正。谢谢!
你写的比较接近。