范文无忧网面试笔试面试回答

SQL语句面试题解

06月28日 编辑 fanwen51.com

[出个Sql面试题!]--总体情况 SELECT a.ID, COUNT(*) AS 总数, SUM(CASE b.STYLE WHEN 0 THEN 1 ELSE 0 END ) AS 过关数, SUM(CASE b.STYLE WHEN 1 THEN 1 ELSE 0 END ) AS 未过关数 from a, b...+阅读

SQL语句面试题解

现场助?我是不是来晚了?

1、SELECT `Sc_name` FROM `score` WHERE `Sc`=0 and `Sc_number` LIKE '98%';

2、SELECT `score.Sc_name`,`score.Sc_score`,`course.Co_name` FROM `score` inner join `course` ON `score.Sc_courseid` = `course.Co_id`;

3、SELECT `Sc_name`,AVG(Sc_score) as "ScAVG" FROM `score` WHERE `Sc_score` < 60 ORDER BY 2 DESC;

4、这题不太理解什么意思。

5、a)合理使用索引; b)尽量避免使用*作为查找字段; c)使用EXISTS代替IN,NOT EXISTS代替NOT IN; d)使用>;=代替>; e)不要在索引列使用IS NULL、IS NOT NULL;

数据库SQL查询语句面试题

5.1

select a.username,b.deptname from users a,dept b where a.dept_id=b.id;

5.2

update users set dept_id='9' where dept_id='2';

5.3

select a.deptname,b.count_id from dept a,(select dept_id,count(id) as count_id from users group by dept_id having count(id)>1) b where a.id=b.dept_id;

5.4

select a.deptname,b.count_man,c.count_woman from dept a,(select dept_id,count(sex) as count_man from users where group by dept_id) b,(select dept_id,count(sex) as count_woman from users where group by dept_id) c where a.id=b.dept_id and a.id=c.dept_id;

5.5

添加历史记录表

create table history(

id number(8), -- 记录编号

dept_id varchar2(5), -- 部门ID

user_id varchar2(5), -- 用户ID

change_date date -- 变动日期

);

有关SQL的面试题。。

1:

〔车辆〕、〔站台〕、〔行车路线〕最少3个表

〔车辆〕表字段〔ID〕,〔名称〕

〔站台〕表字段〔ID〕,〔名称〕,〔描述〕

〔行车路线〕表字段〔ID〕,〔车ID〕,〔站ID〕

查询:

SELECT 〔车辆〕.〔名称〕,〔站台〕.〔名称〕

FROM 〔车辆〕 INNER JOIN 〔行车路线〕

ON 〔车辆〕.〔ID〕=〔行车路线〕.〔车ID〕

INNER JOIN 〔站台〕

ON 〔站台〕.〔ID〕=〔行车路线〕.〔站ID〕

WHERE 〔站台〕.〔名称〕 = '车站1'

OR 〔站台〕.〔名称〕 = '车站2'

2:数据库设计

〔部门〕表:ID,父级ID,名称

〔员工〕表:ID,父级ID,名称,权限

〔员工所属部门〕表:ID,员工ID,部门ID

〔申请〕表:ID,内容,申请人ID,审核人ID,审核结果,备注

系统设计:

1 员工进入申请页面时,根据〔员工〕的权限来判断是否能进入

2 员工查询〔申请〕表,通过申请人ID过滤,只有申请权限

3 经理查询〔申请〕表,通过〔员工〕表查申请人的父级ID过滤,可以进行审批操作

延伸阅读:

SQL语句面试题恩,通过自定义函数吧。。 实现如下: ----创建自定义函数 create function F_Getvarchar(a1 int) returns varchar(8000) as Begin declare a2 varchar(100),Newvarhar varchar...

面试题目sql我使用的是MySQL 如下语句: 建表语句: create table Lessoninfo( no int, week int, isonduty char); 插入数据:略 insert into Lessoninfo values(...............) SQL查询语...

求sql语句怎么写金蝶面试题 MySQL大家论坛第一个select sum(FSAL) as salary from table1 where year(FDATE)=year(now()) and FNAME=\'张三\';第二个select sum(FSAL),sum(FSAL)/52/count(DISTINCT FID),sum(FSAL)/1...

数据库SQL查询语句面试题5.1 select a.username,b.deptname from users a,dept b where a.dept_id=b.id; 5.2 update users set dept_id='9' where dept_id='2'; 5.3 select a.deptname,b.count_id...

急求Sql Server数据库SQL语句面试题What are two methods of retrieving SQL? What cursor type do you use to retrieve multiple recordsets? What is the difference between a “where” clause and a “h...

求SQL题解试题如下解1:select * from tbName where id_no in(select id_no from tbName group by id_no having count(id_no)>1) 解2:select * into #tmpTb from tbName where id_no in(select...

oracle面试题一个SQL语句求解SQL code--举例如下SQL>delete emp 2wherenotexists (select1from3 (select rownum rn,empno from emp) t 4where t.empno=emp.empno and t.rn in(2,5));已删除12行。SQL>sele...

sql语句面试题1.SELECT s.SNO,SNAME FROM S s,SC sc WHERE s.SNO=sc.SNO AND sc.CNO IN(SELECT CNO FROM C WHERE TNO= (SELECT TNO FROM T WHERE)); 2.SELECT SNO FROM SC WHERE CNO IN(...

sql面试题求解sql面试题求解,数据库面试题::方法1:Select * from p a where not exists(select 1 from p where phone=a.phone and calltime>a.calltime)方法2:select a.* from p a join (se...

推荐阅读
图文推荐
栏目列表