Oracle 面试题及答案整理Oracle 面试题及答案整理1、表:table1(FId,Fclass,Fscore),用最高效最简单的 SQL 列出各班成绩最高的列表,显示班级,成绩两个字段。select fclass,max(fscore) from table1 group by fclass,fid2、有一种表 table1 有两个字段 FID,Fno,字都非空,写一种SQL 语句列出该表中一种 FID 对应多种不一样的 Fno 的纪录。类如: 101a1001 101a1001 102a1002 102a1003 103a1004 104a1005 104a1006 105a1007 105a1007 105a1007 成果: 102a1002 102a1003 104a1005 104a1006select t2.* from table1 t1, table1 t2 where t1.fid = t2.fid and t1.fno <> t2.fno;3、有员工表 empinfo ( Fempno varchar2(10) not null pk, Fempname varchar2(20) not null, Fage number not null, Fsalary number not null ); 假如数据量很大概 1000 万条;写一种你认为最高效的 SQL,用一种SQL 计算如下四种人: fsalary>9999 and fage > 35 fsalary>9999 and fage < 35 fsalary <9999 and fage > 35 fsalary <9999 and fage < 35 每种员工的数量; select sum(case when fsalary > 9999 and fage > 35then 1else 0end) as "fsalary>9999_fage>35",sum(case when fsalary > 9999 and fage < 35then 1else 0end) as "fsalary>9999_fage<35",sum(case when fsalary < 9999 and fage > 35then 1else 0end) as "fsalary<9999_fage>35",sum(case when fsalary < 9999 and fage < 35then 1else 0end) as "fsalary<9999_fage<35"from empinfo;4、表 A 字段如下 month person income 月份 人员 收入 规定用一种 SQL 语句(注意是一种)的处所有人(不辨别人员)每月及上月和下月的总收入 规定列表输出为 月份 当月收入 上月收入 下月收入 MONTHS PERSON INCOME---------- ---------- ---------- 07 mantisXF 5000 06 mantisXF2 3500 06 mantisXF3 3000 05 mantisXF1 05 mantisXF6 2 00804 mantisXF7 1800 03 8mantisXF 4000 02 9mantisXF 4 00802 10mantisXF 3300 01 11mantisXF 4600 09 11mantisXF 680011 rows selectedselect months, max(incomes), max(prev_months), max(next_months)from (select months,incomes,decode(lag(mont...