加入收藏 | 设为首页 | 会员中心 | 我要投稿 湖南网 (https://www.hunanwang.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 运营 > 正文

SQL数据库口试题以及谜底(50例题)

发布时间:2020-12-31 12:15:58 所属栏目:运营 来源:网络整理
导读:SQL常晤口试题 1.用一条SQL 语句 查询出每门课都大于80 分的门生姓名 name kecheng fenshu张三 语文 81张三 数学 75李四 语文 76李四 数学 90王五 语文 81王五 数学 100王五 英语 90A: select distinct name from table where name not in (select distinct
副问题[/!--empirenews.page--]

SQL常晤口试题

1.用一条SQL 语句 查询出每门课都大于80 分的门生姓名

name   kecheng   fenshu张三    语文       81张三     数学       75李四     语文       76李四     数学       90王五     语文       81王五     数学       100王五     英语       90A: select distinct name from table where name not in (select distinct name from table where fenshu<=80)select name="" from="" table="" group="" by="" having="">80

2. 门生表 如下:自动编号   学号   姓名 课程编号 课程名称 分数1        2005001 张三 0001     数学    692        2005002 李四 0001      数学    893        2005001 张三 0001      数学    69删除除了自动编号差异, 其他都沟通的门生冗余信息A: delete tablename where 自动编号 not in(select min( 自动编号) from tablename group by学号, 姓名, 课程编号, 课程名称, 分数)

3.一个叫 team 的表,内里只有一个字段name, 一共有4 条记载,别离是a,b,c,d, 对应四个球对,此刻四个球对举办角逐,用一条sql 语句表现全部也许的角逐组合.你先按你本身的设法做一下,当作果有我的这个简朴吗?

答:select a.name,b.namefrom team a,team b where a.name < b.name

4.请用SQL 语句实现:从TestDB 数据表中查询出全部月份的产生额都比101 科目响应月份的产生额高的科目。请留意:TestDB 中有许多科目,都有1 -12 月份的产生额。AccID :科目代码,Occmonth :产生额月份,DebitOccur :产生额。数据库名:JcyAudit ,数据集:Select * from TestDB

5.口试题:怎么把这样一个表儿year   month amount1991   1     1.11991   2     1.21991   3     1.31991   4     1.41992   1     2.11992   2     2.21992   3     2.31992   4     2.4查成这样一个功效year m1   m2   m3   m41991 1.1 1.2 1.3 1.41992 2.1 2.2 2.3 2.4 谜底一、select year, (select amount from   aaa m where month=1   and m.year=aaa.year) as m1,(select amount from   aaa m where month=2   and m.year=aaa.year) as m2,(select amount from   aaa m where month=3   and m.year=aaa.year) as m3,(select amount from   aaa m where month=4   and m.year=aaa.year) as m4from aaa   group by year

6. 声名:复制表( 只复制布局, 源表名:a新表名:b) SQL: select * into b from a where 1<>1       (where1=1,拷贝表布局和数据内容)Oracle:create table b

As

Select * from a where 1=2

[<>(不便是)(SQL Server Compact)

较量两个表达式。 当行使此运算符较量非空表达式时,假如左操纵数不便是右操纵数,则功效为 TRUE。 不然,功效为 FALSE。]

7. 声名:拷贝表( 拷贝数据, 源表名:a方针表名:b) SQL: insert into b(a,c) select d,e,f from a; 8. 声名:表现文章、提交人和最后回覆时刻SQL: select a.title,a.username,b.adddate from table a,(select max(adddate) adddate from table where table.title=a.title) b9. 声名:外毗连查询( 表名1 :a表名2 :b)SQL: select a.a,a.b,a.c,b.c,b.d,b.f from a LEFT OUTER JOIN b ON a.a = b.c

ORACLE:select a.a,b.f from a,b

511. 声名:两张关联表,删除主表中已经在副表中没有的信息SQL: Delete from info where not exists (select * from infobz where info.infid=infobz.infid )

12.有两个表A 和B ,均有key 和value 两个字段,假如B 的key 在A 中也有,就把B 的value 换为A 中对应的value这道题的SQL 语句怎么写?

update b set b.value=(select a.value from a where a.key=b.key) where b.id in(select b.id from b,a where b.key=a.key);

13.高级sql 口试题

原表:courseid coursename score-------------------------------------1 Java 702 oracle 903 xml 404 jsp 305 servlet 80-------------------------------------为了便于阅读, 查询此表后的功效显式如下( 合格分数为60):courseid coursename score mark---------------------------------------------------1 Java 70 pass2 oracle 90 pass3 xml 40 fail4 jsp 30 fail5 servlet 80 pass---------------------------------------------------写出此查询语句

select courseid,coursename,score,decode(sign(score-60),-1,'fail','pass') as mark from course

完全正确SQL> desc course_vName Null? Type----------------------------------------- -------- ----------------------------COURSEID NUMBERCOURSENAME VARCHAR2(10)SCORE NUMBERSQL> select * from course_v;COURSEID COURSENAME SCORE---------- ---------- ----------1 java 702 oracle 903 xml 404 jsp 305 servlet 80SQL> select courseid,decode(sign(score-60),'pass') as mark from course_v;COURSEID COURSENAME SCORE MARK---------- ---------- ---------- ----1 java 70 pass2 oracle 90 pass3 xml 40 fail4 jsp 30 fail5 servlet 80 pass

SQL口试题(1)

create table testtable1(id int IDENTITY,department varchar(12) )

(编辑:湖南网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

热点阅读