全球旧事资料 分类
第一章
SQL经典面试题及答案1用一条SQL语句查询出每门课都大于80分的学生姓名
amekeche
gfe
shu张三语文81张三数学75李四语文76李四数学90王五语文81王五数学100王五英语90Aselectdisti
ct
amefromtablewhere
ame
oti
selectdisti
ct
amefromtablewherefe
shu80
select
amefromtablegroupby
amehavi
gmi
fe
shu80select
amefromtablegroupby
amehavi
gcou
tkeche
g3a
dmi
fe
shu80
2学生表如下自动编号学号姓名课程编号课程名称分数
页脚内容1
f第一章
12005001张三0001数学6922005002李四0001数学8932005001张三0001数学69删除除了自动编号不同其他都相同的学生冗余信息Adeletetable
amewhere自动编号
oti
selectmi
自动编号fromtable
amegroupby学号姓名课程编号课程名称分数
3面试题:怎么把这样一个表儿yearmo
thamou
t19911111991212199131319914141992121199222219923231992424查成这样一个结果
页脚内容2
f第一章yearm1m2m3m4199111121314199221222324答案一、selectyearselectamou
tfromaaamwheremo
th1a
dmyearaaayearasm1selectamou
tfromaaamwheremo
th2a
dmyearaaayearasm2selectamou
tfromaaamwheremo
th3a
dmyearaaayearasm3selectamou
tfromaaamwheremo
th4a
dmyearaaayearasm4fromaaagroupbyyear
4说明:拷贝表拷贝数据源表名:a目标表名:bSQLi
serti
tobabcselectdeffroma
5有一张表,里面有3个字段:语文,数学,英语。其中有3条记录分别表示语文70分,数学80分,英语58分,请用一条sql语句查询出这三条记录并按以下条件显示出来(并写出您的思路):
大于或等于80表示优秀,大于或等于60表示及格,小于60分表示不及格。显示格式:
页脚内容3
f语文数学英语及格优秀不及格selectcasewhe
语文80the
优秀whe
语文60the
及格else不及格as语文casewhe
数学80the
优秀whe
数学60the
及格else不及格as数学casewhe
英语80the
优秀whe
英语60the
及格else不及格as英语fromtable
第一章
6、编写SQL语句1创建一张学生表,包含以下信息,学号,姓名,年龄,性别,家庭住址,联系电话
页脚内容4
fCreatetablestu学号i
t姓名varchar8年龄i
t性别varchar4家庭地址varchar50联系电话i
t
第一章
2修改学生表的结构,添加一列信息,学历Altertablestuadd学历varchar6
3修改学生表的结构,删除一列信息,家庭住址Altertablestudropcolum
家庭地址
4向学生表添加如下信息:学号姓名年龄性别联系电话学历1A22男123456小r
好听全球资料 返回顶部