在SQL中如何使用case...end与as字句

[复制链接]
查看11 | 回复1 | 2011-3-24 11:30:44 | 显示全部楼层 |阅读模式
select cardid as \'账号\',tradeType=
case
when tradeType=1 then \'存款\'
when tradeType=2 then \'取款\'
end
,tradeMoney as \'交易金额\',tradeDate as \'交易日期\' from TradeInfo
go

select cardid as \'账号\',tradeType=
case
when tradeType=1 then \'存款\'
when tradeType=2 then \'取款\'
end
as \'交易类型\',tradeMoney as \'交易金额\',tradeDate as \'交易日期\' from TradeInfo
go
这两个语句
要将图中的tradeType转换成\'交易类型\'
回复

使用道具 举报

千问 | 2011-3-24 11:30:44 | 显示全部楼层
<pre id=\"best-answer-content\" class=\"reply-text mb10\">语句写法有问题
tradeType=
case
when tradeType=1 then \'存款\'
when tradeType=2 then \'取款\'
end
as \'交易类型\',

第一种方法,去掉第一句tradeType=
第二种方法,去掉最后一句
as \'交易类型\'
(保留逗号) ,同时将第一句改为
\'交易类型\' =
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行