读书人

今日的一个SQL题-case语句和decode函数

发布时间: 2013-07-09 09:50:47 作者: rapoo

今天的一个SQL题-case语句和decode函数
select game_time as 比赛日期,(case rst when 'W' then '胜利' when 'F' then '失败' else '无结果'end)结果,count(rst) as 结果统计from recgroup by game_time,rst;

?

记录下:

1. ?decode函数用法:

decode(表达式1,条件1,结果1,[条件2,结果2][default]);

2. ?case 语句:

case 表达式

when 表达式1 then ....

when 表达式2 then ....

else ?......

end 表达式

1 楼 quanwsx 2013-07-02 哦 真不错

读书人网 >SQL Server

热点推荐