<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    將Java進(jìn)行到底
    將Java進(jìn)行到底
    posts - 15,  comments - 66,  trackbacks - 0

    /*
    建表:
    dept:
     deptno(primary key),dname,loc
    emp:
     empno(primary key),ename,job,mgr,sal,deptno
    */

    1 列出emp表中各部門的部門號(hào),最高工資,最低工資
    select max(sal) as 最高工資,min(sal) as 最低工資,deptno from emp group by deptno;

    2 列出emp表中各部門job為'CLERK'的員工的最低工資,最高工資
    select max(sal) as 最高工資,min(sal) as 最低工資,deptno as 部門號(hào) from emp where job = 'CLERK' group by deptno;

    3 對(duì)于emp中最低工資小于1000的部門,列出job為'CLERK'的員工的部門號(hào),最低工資,最高工資
    select max(sal) as 最高工資,min(sal) as 最低工資,deptno as 部門號(hào) from emp as b
    where job='CLERK' and 1000>(select min(sal) from emp as a where a.deptno=b.deptno) group by b.deptno

    4 根據(jù)部門號(hào)由高而低,工資有低而高列出每個(gè)員工的姓名,部門號(hào),工資
    select deptno as 部門號(hào),ename as 姓名,sal as 工資 from emp order by deptno desc,sal asc

    5 寫出對(duì)上題的另一解決方法
    (請(qǐng)補(bǔ)充)

    6 列出'張三'所在部門中每個(gè)員工的姓名與部門號(hào)
    select ename,deptno from emp where deptno = (select deptno from emp where ename = '張三')

    7 列出每個(gè)員工的姓名,工作,部門號(hào),部門名
    select ename,job,emp.deptno,dept.dname from emp,dept where emp.deptno=dept.deptno

    8 列出emp中工作為'CLERK'的員工的姓名,工作,部門號(hào),部門名
    select ename,job,dept.deptno,dname from emp,dept where dept.deptno=emp.deptno and job='CLERK'

    9 對(duì)于emp中有管理者的員工,列出姓名,管理者姓名(管理者外鍵為mgr)
    select a.ename as 姓名,b.ename as 管理者 from emp as a,emp as b where a.mgr is not null and a.mgr=b.empno

    10 對(duì)于dept表中,列出所有部門名,部門號(hào),同時(shí)列出各部門工作為'CLERK'的員工名與工作
    select dname as 部門名,dept.deptno as 部門號(hào),ename as 員工名,job as 工作 from dept,emp
    where dept.deptno *= emp.deptno and job = 'CLERK'

    11 對(duì)于工資高于本部門平均水平的員工,列出部門號(hào),姓名,工資,按部門號(hào)排序
    select a.deptno as 部門號(hào),a.ename as 姓名,a.sal as 工資 from emp as a
    where a.sal>(select avg(sal) from emp as b where a.deptno=b.deptno) order by a.deptno

    12 對(duì)于emp,列出各個(gè)部門中平均工資高于本部門平均水平的員工數(shù)和部門號(hào),按部門號(hào)排序
    select count(a.sal) as 員工數(shù),a.deptno as 部門號(hào) from emp as a
    where a.sal>(select avg(sal) from emp as b where a.deptno=b.deptno) group by a.deptno order by a.deptno

    13 對(duì)于emp中工資高于本部門平均水平,人數(shù)多與1人的,列出部門號(hào),人數(shù),按部門號(hào)排序
    select count(a.empno) as 員工數(shù),a.deptno as 部門號(hào),avg(sal) as 平均工資 from emp as a
    where (select count(c.empno) from emp as c where c.deptno=a.deptno and c.sal>(select avg(sal) from emp as b where c.deptno=b.deptno))>1
    group by a.deptno order by a.deptno

    14 對(duì)于emp中低于自己工資至少5人的員工,列出其部門號(hào),姓名,工資,以及工資少于自己的人數(shù)
    select a.deptno,a.ename,a.sal,(select count(b.ename) from emp as b where b.sal<a.sal) as 人數(shù) from emp as a
    where (select count(b.ename) from emp as b where b.sal<a.sal)>5


    轉(zhuǎn)自:http://blog.csdn.net/woolceo/archive/2006/03/02/614094.aspx

    posted on 2006-03-04 20:31 風(fēng)蕭蕭 閱讀(2046) 評(píng)論(1)  編輯  收藏 所屬分類: 雜談

    FeedBack:
    # re: 轉(zhuǎn):數(shù)據(jù)庫(kù)筆試題
    2008-06-02 16:55 | 啊啊啊
    對(duì)面試很有幫助!  回復(fù)  更多評(píng)論
      

    <2008年6月>
    25262728293031
    1234567
    891011121314
    15161718192021
    22232425262728
    293012345

    常用鏈接

    留言簿(8)

    隨筆分類

    隨筆檔案

    文章分類

    文章檔案

    相冊(cè)

    收藏夾

    myfriends

    opensource

    搜索

    •  

    最新評(píng)論

    閱讀排行榜

    評(píng)論排行榜

    主站蜘蛛池模板: 亚洲三级在线视频| 亚洲天堂在线视频| 免费观看激色视频网站bd| 午夜免费福利小电影| 99精品免费观看| 免费看的成人yellow视频| 四虎AV永久在线精品免费观看| 亚洲日本一区二区一本一道 | 香蕉高清免费永久在线视频| 亚洲1区1区3区4区产品乱码芒果 | 色老板亚洲视频免在线观| 欧洲乱码伦视频免费国产| 91国内免费在线视频| 波多野结衣免费在线| 亚洲综合色视频在线观看| 国产成人无码精品久久久免费| 99久久免费精品高清特色大片| 亚洲欧洲日产国产综合网| 亚洲国产无线乱码在线观看| a在线免费观看视频| 免费看男女下面日出水视频| 黄色免费在线观看网址| 成年轻人网站色免费看| 亚洲精品自产拍在线观看| 亚洲人成777在线播放| a在线观看免费网址大全| 亚洲成aⅴ人片在线观| 免费看黄的成人APP| 亚洲高清不卡视频| 免费福利在线视频| 国产亚洲精品精华液| 91频在线观看免费大全| 美女啪啪网站又黄又免费| 亚洲AV无码久久精品蜜桃| a高清免费毛片久久| 久久久亚洲欧洲日产国码aⅴ | 久久这里只精品国产免费10| 亚洲精品夜夜夜妓女网| 精品国产sm捆绑最大网免费站| 美女视频黄a视频全免费网站一区| 国产成A人亚洲精V品无码 |