我拥有的这个功能可以满足我的需求,但只是想知道是否有办法一次性完成:
drop table ##aa
select s.storeid,cast(LEFT(p.paytype,1) as varchar(50)) as Paytype,SUM(amount) as Total
into ##aa
from RPTrs s, rpPay p
where s.storeid=p.StoreID and s.ReceiptNO=p.ReceiptNo
and trsdate between '1/1/06' and '1/1/13'
group by s.storeid,LEFT(p.paytype,1)
update A set a.paytype=b.currencydesc
from ##aa a, Currencies b
where a.Paytype=b.POSCurrency
select * from ##aa order by Paytype, StoreID
我要问的是,我想将 b.CurrencyDesc 应用于初始 p.paytype。Paytype 仅显示 C 作为示例,但我希望它代表现金,V 代表 Visa,如货币表中所述