sql in excel Switch函数Word下载.docx
《sql in excel Switch函数Word下载.docx》由会员分享,可在线阅读,更多相关《sql in excel Switch函数Word下载.docx(4页珍藏版)》请在冰豆网上搜索。
将成绩分等级。
60以下D;
60-80以下
C;
80-90以下B;
90-100A。
sql语句:
select成绩,
switch(成绩<
60,'
D'
成绩<
80,'
C'
90,'
B'
=100,'
A'
)as等级
from[Sheet1$]
orderby成绩
结果:
除了返回等级之外,Switch函数其实和vba中的select--endselect结构有点类似。
返回每个城市的国家。
select城市,
switch(城市='
北京'
'
中国'
城市='
纽约'
美国'
巴黎'
法国'
柏林'
德国'
伦敦'
英国'
)as国家
from[Sheet2$]
switch函数也可以用iif函数来代替,如第一个栗子。
iif(成绩<
)))as等级
返回结果: