SQL SELECT Replace country names with abbreviations -
my query looks this:
select o.customerid, null emptycolumn, o.shipfirstname, o.shipcountry, c.emailaddress orders o, customers c o.customerid = c.customerid
and results like,
1,,john,united states,john@example.com 2,,peter,canada,peter@example.com
but need change "united states" "us" , "canada" "ca". how can this?
you can use case
,
select o.customerid, null emptycolumn, o.shipfirstname, case when o.shipcountry = 'united states' 'us' when o.shipcountry = 'canada' 'ca' end, c.emailaddress orders o, customers c o.customerid = c.customerid
Comments
Post a Comment