全球旧事资料 分类
SQL经典面试题及答案
1一道SQL语句面试题,关于groupby表内容:20050509胜20050509胜20050509负20050509负20050510胜20050510负20050510负如果要生成下列结果该如何写sql语句胜负20050509222005051012createtabletmprqvarchar10she
gfu
char1i
serti
serti
serti
serti
serti
serti
serti
toi
toi
toi
toi
toi
toi
totmptmptmptmptmptmptmpvalues20050509胜values20050509胜values20050509负values20050509负values20050510胜values20050510负values20050510负
1selectrqsumcasewhe
she
gfu胜the
1else0e
d胜sumcasewhe
she
gfu负the
1else0e
d负fromtmpgroupbyrq2selectNrqNMfromselectrqcou
tfromtmpwhereshe
gfu胜groupbyrqNi
erjoi
selectrqcou
tfromtmpwhereshe
gfu负groupbyrqMo
NrqMrq3selectacol001aa1胜bb1负fromselectcol001cou
tcol001a1fromtemp1wherecol002胜groupbycol001aselectcol001cou
tcol001b1fromtemp1wherecol002负groupbycol001bwhereacol001bcol0012请教一个面试中遇到的SQL语句的查询问题表中有ABC三列用SQL语句实现:当A列大于B列时选择A列否则选择B列,
f当B列大于C列时选择B列否则选择C列。selectcasewhe
abthe
aelsebe
dcasewhe
bcthe
beslece
dfromtable_
ame3面试题:一个日期判断的sql语句?请取出tb_se
d表中日期Se
dTime字段为当天的所有记录Se
dTime字段为datetime型,包含日期与时间selectfromtbwheredatediffddSe
dTimegetdate04有一张表,里面有3个字段:语文,数学,英语。其中有3条记录分别表示语文70分,数学80分,英语58分,请用一条sql语句查询出这三条记录并按以下条件显示出来(并写出您的思路):大于或等于80表示优秀,大于或等于60表示及格,小于60分表示不及格。显示格式:语文数学英语及格优秀不及格selectcasewhe
语文80the
优秀whe
语文60the
及格else不及格as语文casewhe
数学80the
优秀whe
数学60the
及格else不及格as数学casewhe
英语80the
优秀whe
英语60the
及格else不及格as英语fromtable5在sqlserver2000中请用sql创建一张用户临时表和系统临时表,里面包含两个字段ID和IDValues类型都是i
t型,并解释下两者的区别用户临时表createtablexxIDi
tIDValuesi
t系统临时表createtablexxIDi
tIDValuesi
t区别用户临时表r
好听全球资料 返回顶部