Oracle資料庫面試練習題
1.列出至少有一個員工的所有部門。
分析:每個部門有多少員工 —— 根據部門編號進行分組
select deptno,count(*) from emp group by deptno having count(*) >= 1;
2.列出薪金比“smith”多的所有員工。
分析:先查詢出smith工資 : select sal from emp where ename=’smith’;
select * from emp where sal > (select sal from emp where ename=’smith’);
3.***** 列出所有員工的姓名及其直接上級的姓名。
分析:表自對映,為表起別名,進行關聯 t1 表模擬員工表 t2 表儲存直接上級資訊
select e 員工姓名, e 直接上級 from emp t1,emp t2 where = o;
4.列出受僱日期早於其直接上級的所有員工。
分析:原理和上題類似
select t1.*,date from emp t1,emp t2 where = o and date < date;
5.列出部門名稱和這些部門的員工資訊,同時列出那些沒有員工的部門。
分析:部門沒員工也要顯示 — 外連線。無論怎樣部門資訊一定要顯示,通過部門去關聯員工
select * from dept left outer join emp on no = no ;
6.列出所有“clerk”(辦事員)的姓名及其部門名稱。
分析:查詢job為clerk 員工姓名和部門名稱
員工姓名 emp表
部門名稱 dept表
select e,e, from emp,dept where no = no and =’clerk’;
7.列出最低薪金大於1500的各種工作。
分析:工作的最低薪金 —- 按工作分組,求最低薪金
select min(sal) from emp group by job;
大於1500 是一個分組條件 — having
select job,min(sal) from emp group by job having min(sal) > 1500;
8.列出在部門“sales”(銷售部)工作的員工的姓名,假定不知道銷售部的部門編號。
分析:員工姓名位於 emp 部門名稱 dept
select e from emp,dept where no = no and e = ‘sales’;
9.列出薪金高於公司平均薪金的所有員工。
分析:先求公司平均薪金 select avg(sal) from emp;
select * from emp where sal > (select avg(sal) from emp);
10.列出與“scott”從事相同工作的所有員工。
分析:先查詢scott : select job from emp where ename =’scott’;
select * from emp where ename <> ‘scott’ and job = (select job from emp where ename =’scott’);
11.列出薪金等於部門30中員工的薪金的所有員工的姓名和薪金。
分析:檢視部門30 中所有員工薪資列表 select sal from emp where deptno = 30;
select * from emp where sal in (select sal from emp where deptno = 30);
12.列出薪金高於在部門30工作的所有員工的薪金的員工姓名和薪金。
分析:
select * from emp where sal > all(select sal from emp where deptno = 30);
select * from emp where sal > (select max(sal) from emp where deptno = 30);
13.列出在每個部門工作的員工數量、平均工資。
分析:按部門分組
select deptno, count(*),avg(sal) from emp group by deptno;
14.列出所有員工的姓名、部門名稱和工資。
分析:
select e,e, from emp,dept where no = no;
15.列出所有部門的詳細資訊和部門人數。
分析:
select dept.*,count(emp.*) from emp,dept where no = no group by deptno ; 錯誤!
求各個部門編號和人數 select deptno,count(*) from emp group by deptno;
再和dept表關聯 select dept.*,temp.部門人數 from dept , (select deptno,count(*) 部門人數 from emp group by deptno) temp where no = no ;
16.列出各種工作的最低工資。
分析:各個工作 分組 , 最低工資 min
select job,min(sal) from emp group by job;
17.列出各個部門的manager(經理)的最低薪金。
分析:where job=’manager’ 過濾所有不是經理資料
select deptno,min(sal) from emp where job =’manager’ group by deptno;
18.列出所有員工的年工資,按年薪從低到高排序。
分析: select ename, sal*12 from emp order by sal*12 asc;
19.查出emp表中薪水在3000以上(包括3000)的所有員工的員工號、姓名、薪水。
分析: select * from emp where sal >= 3000;
20.查詢出所有薪水在’allen’之上的所有人員資訊。
分析:select * from emp where sal > (select sal from emp where ename =’allen’);
21.查詢出emp表中部門編號為20,薪水在XX以上(不包括XX)的所有員工,顯示他們的員工號,姓名以及薪水,以如下列名顯示:員工編號 員工名字 薪水
分析: select empno 員工編號,ename 員工姓名 ,sal 薪水 from emp where deptno = 20 and sal > XX;
22.查詢出emp表中所有的工作種類(無重複)
分析: select distinct job from emp;
23.查詢出所有獎金(comm)欄位不為空的人員的所有資訊。
分析:不為空 is not null
select * from emp where comm is not null;
24.查詢出薪水在800到2500之間(閉區間)所有員工的資訊。(注:使用兩種方式實現and以及between and)
分析:select * from emp where sal >= 800 and sal <= 2500;
select * from emp where sal between 800 and 2500;
25.查詢出員工號為7521,7900,7782的所有員工的資訊。(注:使用兩種方式實現,or以及in)
分析:select * from emp where empno in(7521,7900,7782);
select * from emp where empno=7521 or empno = 7900 or empno = 7782;
26.查詢出名字中有“a”字元,並且薪水在1000以上(不包括1000)的所有員工資訊。
分析: 模糊查詢
select * from emp where ename like ‘%a%’ and sal > 1000;
27.查詢出名字第三個字母是“m”的所有員工資訊。
分析:第三個字母 __m%
select * from emp where ename like ‘__m%’;
28.將所有員工按薪水升序排序,薪水相同的按照入職時間降序排序。
分析:select * from emp order by sal asc,hiredate desc;
29.將所有員工按照名字首字母升序排序,首字母相同的按照薪水降序排序。
分析:substring(‘字串’,第幾個字元,長度); —- 首字母 substring(ename,1,1)
select * from emp order by substring(ename,1,1) asc,sal desc;
-
面試常見問題:你所取得的最大成就是什麼
問題:你所取得的最大成就是什麼?回答:從你過去或目前的相關工作中,找出具體的例項來加以說明。如為了舉辦校園歌手比賽,成功地聯絡了一家企業作為贊助商,使比賽開展的很成功,或大三開始,自己邊學習,邊工作,勤工助學,生活不依靠父母,完全自立等等。點評:進一步瞭解你的能力...
-
面試中暗藏陷阱的問題,你答對了麼?
面試過程中,面試官會向求職者發問,而求職者的思維方式和回答是面試官考慮是否錄用他的重要參考。對求職者來說,這些問題背後都隱藏著鮮為人知的陷阱,如何才能不掉進這些問題背後隱藏的陷阱呢?瀚哥對面試中暗藏陷阱的問題進行了整理,並總結了回答思路,希望大家可以活...
-
海南海事局國考面試真題
1.海上搜救是否要不計成本?【試題類別】綜合分析類試題【考查要素】綜合分析能力、解決問題能力、快速反應能力【思路點撥】對於綜合分析題目我們的思路是要首先分析海上搜救的現狀和意義,接著再考慮回答是否要不計成本,並且解釋為什麼,然後思考有沒有更好的解決...
-
面試題:講解實習經歷
你的簡歷中提到你曾經在er公司實習過,能講講這段實習經歷嗎?a.我就做了1個月,比較短,沒有太多實質性的工作,就是整理相關資料,負責定會議室等。b.我在er做了三個月,最初是一個專案進去實習的,後來專案完成後我的上司認為我做的還可以,就留下來繼續外聯的工作,我覺得er的...
相關文章
- Cover Letter Sample of Rail Yard Engineer
- the Sample of Chronological Resume英文簡歷模板
- 英文簡歷9--CONTROLLER(General)-resume.doc
- The Social Value of the College-Bred - 英語演講稿
- Obama's Weekly Address:Closing Corporate Tax Loopholes
- 大學生英語演講稿 Knowledge collaboration and all-round education
- B-School Graduates Face An Aray of Closed Doors
- Employee Referral Cover Letter
- Laughter really is the best medicine for cancer pa
- TED英文演講稿:Why you will fail to have a great career大綱