This function that I have does what I want, but just wondering if there is a way to do it in one go:
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
What I am asking is, I want to apply the b.CurrencyDesc to the initial p.paytype. The Paytype just displays C as example but I want it to stand for Cash, and V for Visa and such as it is described in the Currencies table
Seems like you can add a
JOIN:Converted to use explicit join syntax. Can’t tell what table contributes
trsdate. And I’m not sure theCASTis needed on the join condition.