【正文】
(,0))。MARTIN39。MARTIN39。 查找出不屬于任何部門的員工 select * from emp where deptno is null or deptno not in(select deptno from dept)。) group by deptno )t where = 。 方法三: select as 部門號, as 部門名稱, ( select count(*) from (select deptno from emp where deptno in (select deptno from emp where ename=39。 查詢出 king 所在部門的工作年限最大的員工名字 select ename, hiredate from emp where hiredate in (select min(hiredate) from emp where deptno in (select deptno from emp where ename=39。 select , from dept d, (select * from (select deptno,sum(sal) sum_sal from emp group by deptno order by desc) where rownum=1 )t where = 。 select e.* from emp1 e,(select id from emp1 minus select id from sext) s where = 。 性別 sext) select * from emp1 where id not in (select from emp1, sext where = )。 面試題三(上海) 人員情況表(employee)中字段包括,員工號(ID)姓名(name)年齡(age)文化程 度 , , , (wh)包括四種情況(本科以上,大專,高中,初中以下),現(xiàn)在我要根據(jù)年齡字段查 詢 : 統(tǒng)計出:表中文化程度為本科以上,大專,高中,初中以下,各有多少人,占總人數(shù)多 少。s two table STUDENT and SCORE_RANK, write a SQL, list all student39。 2. Here?s two table STUDENT and SCORES, a student who have 3 or more courses rank ?A? is a ?GOOD LEARNER?, write a SQL, list all ?GOOD LEARNER? ?s name. Table STUDENT COLUMN NAME COLUMN TYPE Comment ID char(9) not nullable Student?s ID NAME Varchar(30) not nullable Student?s Name Table SCORE COLUMN NAME COLUMN TYPE Comment STUDENT_ID char(9) not nullable Student?s ID COURSE_ID Int not nullable Course ID SCORE Int not nullable Stuend?s score of this course Select name from student,(Select student_id from score,rank where score between lo_score and 32 Oracle 教程 hi_score and rank=?A? id=。 insert into student values(2,39。陳紅39。)。文科39。,39。 小明選了陳紅老師的數(shù)學 insert into choose_course values(2,1,1,2)。 ? select * from student stu where in (select distinct from teacher t,choose_course cc where = and =39。陳紅39。 and = 39。陳紅39。 面試題六(廈門) 8:0012:00 為遲到, 12:0018:00 為早退 打卡表 card SQL create table card( cid number(20), ctime date, cuser number(20))。 insert into person values(2,39。2009071908020039。 insert into card values(2,to_date(39。),1)。yyyymmddhh24miss39。,39。2009072008020039。 insert into card values(6,to_date(39。),1)。yyyymmddhh24miss39。,39。yyyymmdd39。hh24mi39。 35 Oracle 教程 把上面的分析做成一個視圖,判斷上班時間是否為遲到 和 下班時間是否為早退 錄 , 就 改 成 如 果 判 斷 前 10 天 的 打 卡 記 to_char(,39。) select as person_name, as work_day, as AM, as PM, 判斷遲到 case when between 39。 then 39。 end as later, 判斷早退 case when between 39。 then 39。 end as leave_early from 員工表 person p, 上面那張視圖表 (select as id, to_char(,39。) as mindate, to_char(max(),39。)=to_char(sysdate1,39。) ) e1 where = 。 假如數(shù)據(jù)量很大約 1000 萬條; 寫一個你認為最高效的 SQL, 用一個 SQL 計算以下四種人: fsalary9999 and fage 35 fsalary9999 and fage 35 fsalary9999 and fage 35 fsalary9999 and fage 35 每種員工的數(shù)量; select sum(case when 9999 and fage 35 then 1 else 0 end) as fsalary9999 and fage 35, sum(case when 9999 and fage 35 then 1 else 0 end) as fsalary9999 and fage 35, 38 Oracle 教程 sum(case when 9999 and fage 35 then 1 else 0 end) as fsalary9999 and fage 35, sum(case when 9999 and fage 35 then 1 else 0 end) as fsalary9999 and fage 35 from empinfo tt。勝39。負39。負39。一月份39。二月份39。三月份39。 、查詢員工信息與其中工資最高最低員工 select ename,sal,max(sal) over(), min(sal) over() from emp。 41 Oracle 教程 、分部門連續(xù)求和 select deptno,sal ,sum(sal) over (partition by deptno order by ename) as s from emp。 42 Oracle 教程 、確定一年內(nèi)的天數(shù) select dual。y39。 select student_id,count(distinct cid) from choose_course group by student_id having count(distinct cid) = (select count(distinct cid)from course)。EMP39。CAREUSERHAM39。%TABLE%39。 V$controlfile V$datafile。 不行,因 為是 四舍五入) Number 默認為 38 位 44 Oracle 教程 、char,nchar,varchar2,nvarchar2 區(qū)別 、Java 對 blob 字段的操作 第十一章 Oracle 體系結構(DBA) 、數(shù)據(jù)庫(Database) 一系列物理文件(數(shù)據(jù)文件,控制文件,聯(lián)機日志等)的集合或與之對應的邏輯結構(表 空間,段等)被稱為數(shù)據(jù)庫 物理存儲結構 數(shù)據(jù)文件、重做日志文件、控制文件 Desc v$logfile。EMP39。EMP39。SCOTT39。 select * from (select deptno,ename,sal,row_number() over (partition by deptno order by sal desc) rn from emp) where rn3。y39。 month person ine 月份 人員 收入 要求用一個 SQL 語句,統(tǒng)計每個月及上月和下月的總收入 要求列表輸出為 月份 當月收入 上月收入 下月收入 select month,sum(ine),lead(sum(ine)) over(order by sum(ine)) from table group by month。 sum(sal) over(order by ename) ename 來排序的。 select id, Count(*) from tb group by id having count(*)1 第八章 高級查詢 、隨機返回 5 條記錄 Select * from (select ename,job from emp order by ()) where rownum=5 40 Oracle 教程 、處理空值排序 select * from emp order by m desc nulls last(first)。三月份39。二月份39。一月份39。勝39。負39。勝39。 select from a a1, a a2 where and = and = and = 面試題八(福州) 用一條 SQL 語句 查詢出每門課都大于 80 分的學生姓名 name 張三 張三 李四 李四 王五 王五 王五 kecheng 語文 數(shù)學 語文 數(shù)學 語文 數(shù)學 英語 fenshu 81 75 76 90 81 100 90 select Distinct And name from TEST A Where Not Exists(Select * from TEST Where Name = fenshu=80) select from group having name test by name min(fenshu)80 select name from test where name not in(select name from test where fens hu=80) 面試題九(福州) 有一表 table1 有兩個字段 FID,F(xiàn)no,寫一個 SQL 語句列出該表中一個 FID 對應多個不同 的 Fno 的紀 錄。) group by ,to_char(,39。) as maxdate from card c,person p where = and to_char(,39。) as day, to_char(min(),39。 else 39。 and 39。 else 39。 and 39。)=to_char(sysdate10,39。yyyymmdd39。hh24mi39。),2)。 insert into card values(8,to_date(39。2009072007020039。,39。yyyymmddhh24miss39。),2)。 insert into card values(4,to_date(39。2009071909020039。,39。yyyymmddhh24miss39。)。a39。 ? select , from teacher t, ( select tid,cou from (select tid,count(distinct sid) cou from choose_course group by tid order by cou) t1 where rownum=1) t2 where = 。 )。 ? select * from teacher where tid in ( select distinct tid from choose_course cc,student s,course c where = and = and = 39。)。 小明選了陳白老師的語文 insert into choose_course values(1,1,2,1)。)。 insert into course values(2,39。語文39。 insert into teacher values(2,