SQL数据库经典面试题修改笔试题有答案 .doc





《SQL数据库经典面试题修改笔试题有答案 .doc》由会员分享,可在线阅读,更多相关《SQL数据库经典面试题修改笔试题有答案 .doc(39页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、28.数据库:抽出部门,平均工资,要求按部门的字符串顺序排序,不能含有human resource部门,employee结构如下:employee_id, employee_name,depart_id,depart_name,wage答:select depart_name, avg(wage)from employee where depart_name human resourcegroup by depart_name order by depart_name-29.给定如下SQL数据库:Test(num INT(4) 请用一条SQL语句返回num的最小值,但不许使用统计功能,如MIN
2、,MAX等答:select top 1 num from Test order by num -33.一个数据库中有两个表:一张表为Customer,含字段ID,Name;一张表为Order,含字段ID,CustomerID(连向Customer中ID的外键),Revenue;写出求每个Customer的Revenue总和的SQL语句。建表 create table customer(ID int primary key,Name char(10)gocreate table order(ID int primary key,CustomerID int foreign key referen
3、ces customer(id) , Revenue float)go-查询select , sum( isnull(Order.Revenue,0) )from customer full join order on( order.customerid= )group by select ,sum(er) from order,customer where =customerid group by select , sum(er ) from customer full join order on( merid= ) group by 5数据库(10)a tabel called “perf
4、ormance”contain :name and score,please 用SQL语言表述如何选出score最high的一个(仅有一个)仅选出分数,Select max(score) from performance 仅选出名字,即选出名字,又选出分数:select top 1 score ,name from per order by scoreselect name1,score from per where score in/=(select max(score) from per).4 有关系 s(sno,sname) c(cno,cname) sc(sno,cno,grade)
5、1 问上课程 db的学生no select count(*) from c,sc where ame=db and o=oselect count(*) from sc where cno=(select cno from c where ame=db)2 成绩最高的学生号 select sno from sc where grade=(select max(grade) from sc )3 每科大于90分的人数select ame,count(*) from c,sc where o=o and sc.grade90 group by ameselect ame,count(*) from
6、 c join sc on o=o and sc.grade90 group by ame数据库笔试题 *建表:dept:deptno(primary key),dname,locemp:empno(primary key),ename,job,mgr,sal,deptno*/ 1 列出emp表中各部门的部门号,最高工资,最低工资select max(sal) as 最高工资,min(sal) as 最低工资,deptno from emp group by deptno;2 列出emp表中各部门job为CLERK的员工的最低工资,最高工资select max(sal) as 最高工资,min
7、(sal) as 最低工资,deptno as 部门号 from emp where job = CLERK group by deptno;3 对于emp中最低工资小于1000的部门,列出job为CLERK的员工的部门号,最低工资,最高工资select max(sal) as 最高工资,min(sal) as 最低工资,deptno as 部门号 from emp as bwhere job=CLERK and 1000(select min(sal) from emp as a where a.deptno=b.deptno) group by b.deptno4 根据部门号由高而低,工资
8、有低而高列出每个员工的姓名,部门号,工资select deptno as 部门号,ename as 姓名,sal as 工资 from emp order by deptno desc,sal asc5 写出对上题的另一解决方法(请补充)6 列出张三所在部门中每个员工的姓名与部门号select ename,deptno from emp where deptno = (select deptno from emp where ename = 张三)7 列出每个员工的姓名,工作,部门号,部门名select ename,job,o, from emp,dept where o=o8 列出emp中工
9、作为CLERK的员工的姓名,工作,部门号,部门名select ename,job,o,dname from emp,dept where o=o and job=CLERK9 对于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.empno10 对于dept表中,列出所有部门名,部门号,同时列出各部门工作为CLERK的员工名与工作select dname as 部门名,o as 部门号,en
10、ame as 员工名,job as 工作 from dept,emp where o *= o and job = CLERK11 对于工资高于本部门平均水平的员工,列出部门号,姓名,工资,按部门号排序select a.deptno as 部门号,a.ename as 姓名,a.sal as 工资 from emp as awhere a.sal(select avg(sal) from emp as b where a.deptno=b.deptno) order by a.deptno12 对于emp,列出各个部门中平均工资高于本部门平均水平的员工数和部门号,按部门号排序select co
11、unt(a.sal) as 员工数,a.deptno as 部门号 from emp as awhere a.sal(select avg(sal) from emp as b where a.deptno=b.deptno) group by a.deptno order by a.deptno13 对于emp中工资高于本部门平均水平,人数多与1人的,列出部门号,人数,按部门号排序select count(a.empno) as 员工数,a.deptno as 部门号,avg(sal) as 平均工资 from emp as awhere (select count(c.empno) fro
12、m emp as c where c.deptno=a.deptno and c.sal(select avg(sal) from emp as b where c.deptno=b.deptno)1group by a.deptno order by a.deptno14 对于emp中低于自己工资至少5人的员工,列出其部门号,姓名,工资,以及工资少于自己的人数select a.deptno,a.ename,a.sal,(select count(b.ename) from emp as b where b.sala.sal) as 人数 from emp as awhere (select
13、count(b.ename) from emp as b where b.sal5数据库笔试题及答案第一套一.选择题1. 下面叙述正确的是CCBAD _。A、算法的执行效率与数据的存储结构无关B、算法的空间复杂度是指算法程序中指令(或语句)的条数C、算法的有穷性是指算法必须能在执行有限个步骤之后终止D、以上三种描述都不对2. 以下数据结构中不属于线性数据结构的是_。A、队列B、线性表C、二叉树D、栈3. 在一棵二叉树上第5层的结点数最多是_。A、8 B、16 C、32 D、154. 下面描述中,符合结构化程序设计风格的是_。A、使用顺序、选择和重复(循环)三种基本控制结构表示程序的控制逻辑B、
14、模块只有一个入口,可以有多个出口C、注重提高程序的执行效率 D、不使用goto语句5. 下面概念中,不属于面向对象方法的是_。A、对象 B、继承 C、类 D、过程调用6. 在结构化方法中,用数据流程图(DFD)作为描述工具的软件开发阶段是_ BDBCA _。A、可行性分析 B、需求分析 C、详细设计 D、程序编码7. 在软件开发中,下面任务不属于设计阶段的是_。A、数据结构设计 B、给出系统模块结构 C、定义模块算法 D、定义需求并建立系统模型8. 数据库系统的核心是_。A、数据模型 B、数据库管理系统 C、软件工具 D、数据库9. 下列叙述中正确的是_。A、数据库是一个独立的系统,不需要操作
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- SQL数据库经典面试题修改笔试题有答案 SQL 数据库 经典 试题 修改 笔试 答案

限制150内