Go homepage(回首页)
Upload pictures (上传图片)
Write articles (发文字帖)

The author:(作者)delv
published in(发表于) 2013/12/30 4:38:04
SQL,Server面试题整合_mssql学习_编程技术

SQL Server面试题整合_mssql学习_编程技术-你的首页-uuhomepage.com
3。表内容如下
-----------------------------
ID LogTime
1 2008/10/10 10:00:00
1 2008/10/10 10:03:00
1 2008/10/10 10:09:00
2    2008/10/10 10:10:00
2    2008/10/10 10:11:00
......
-----------------------------
请问各位高手,如何查询登陆时间间隔不超过5分钟的所有记录.
几道经典的SQL笔试题目(有答案)
(2)表名:成绩表
姓名 课程 分数
张三 语文 81
张三 数学 75
李四 语文 56
李四 数学 90
王五 语文 81
王五 数学 100
王五 英语 49
……
(其他用户实验的记录大家可自行插入)
给出成绩全部合格的学生信息(包含姓名、课程、分数),注:分数在60以上评为合格
select * from score
where s_name not in
(select s_name from score
where score<60)
或者:
select * from score where s_name in
(select s_name from score
group by s_name
having min(score)>=60)
(3)表名:商品表
名称 产地 进价
苹果 烟台 2.5
苹果 云南 1.9
苹果 四川 3
西瓜 江西 1.5
西瓜 北京 2.4
……
(其他用户实验的记录大家可自行插入)
给出平均进价在2元以下的商品名称
select 名称 from 商品表 group by 名称 having avg(进价) < 2
(4)表名:高考信息表
准考证号 科目 成绩
2006001 语文 119
2006001 数学 108
2006002 物理 142
2006001 化学 136
2006001 物理 127
2006002 数学 149
2006002 英语 110
2006002 语文 105
2006001 英语 98
2006002 化学 129
……
(其他用户实验的记录大家可自行插入)
给出高考总分在600以上的学生准考证号
select 准考证号 from 高考信息表 group by 准考证号 having sum(成绩) > 600
(5)表名:高考信息表
准考证号 数学 语文 英语 物理 化学
2006001 108 119 98 127 136
2006002 149 105 110 142 129
……
(其他用户实验的记录大家可自行插入)
给出高考总分在600以上的学生准考证号
select 准考证号 from 高考信息表 where (数学+语文+英语+物理+化学) > 600
(四部分)
(一)表名:club
id gender age
67 M 19
68 F 30
69 F 27
70 F 16
71 M 32
……(其余测试数据请自行插入)
查询出该俱乐部里男性会员和女性会员的总数
select gender,count(id) from club group by gender
(二)表名:team
ID(number型) Name(varchar2型)
1 a
2 b
3 b
4 a
5 c
6 c
要求:执行一个删除语句,当Name列上有相同时,只保留ID这列上值小的
例如:删除后的结果应如下:
ID(number型) Name(varchar2型)
1 a
2 b
5 c
请写出SQL语句。
delete from team where id not in
(
select min(a1.id) from team a1
where a1.name=team.name )
delete from team where id not in
(
select min(id) from team group by name)
(三)表名:student
name course score
张青 语文 72
王华 数学 72
张华 英语 81
张青 物理 67
李立 化学 98
张燕 物理 70
张青 化学 76
查询出“张”姓学生中平均成绩大于75分的学生信息
select * from student where name in
(select name from student
where name like '张%'
group by name having avg(score) > 75)




If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)





QQ:154298438
QQ:417480759