|
SQL Server面试题整合_mssql学习_编程技术-你的首页-uuhomepage.com3。表内容如下 ----------------------------- 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 scorewhere 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 语文 1192006001 数学 1082006002 物理 1422006001 化学 1362006001 物理 1272006002 数学 1492006002 英语 1102006002 语文 1052006001 英语 982006002 化学 129……(其他用户实验的记录大家可自行插入)给出高考总分在600以上的学生准考证号select 准考证号 from 高考信息表 group by 准考证号 having sum(成绩) > 600(5)表名:高考信息表准考证号 数学 语文 英语 物理 化学2006001 108 119 98 127 1362006002 149 105 110 142 129……(其他用户实验的记录大家可自行插入)给出高考总分在600以上的学生准考证号select 准考证号 from 高考信息表 where (数学+语文+英语+物理+化学) > 600(四部分)(一)表名:clubid gender age67 M 1968 F 3069 F 2770 F 1671 M 32……(其余测试数据请自行插入)查询出该俱乐部里男性会员和女性会员的总数select gender,count(id) from club group by gender(二)表名:teamID(number型) Name(varchar2型)1 a2 b3 b4 a5 c6 c要求:执行一个删除语句,当Name列上有相同时,只保留ID这列上值小的例如:删除后的结果应如下:ID(number型) Name(varchar2型)1 a2 b5 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)(三)表名:studentname course score张青 语文 72王华 数学 72张华 英语 81张青 物理 67李立 化学 98张燕 物理 70张青 化学 76查询出“张”姓学生中平均成绩大于75分的学生信息select * from student where name in (select name from studentwhere name like '张%' group by name having avg(score) > 75)
|