SQL select case

select var_id, program_id, case merchant_id
when '200' then 'bestbuy'
when '300' then 'Replink'
when '500' then 'Buy.com'
when '30000' then 'ALMO'
when '30025' then 'BabyAge.com'
when '30050' then 'Bambeco'
when '30225' then 'cooking.com'
when '30060' then 'Bass Pro Shops'
when '30225' then 'Cooking.com'
when '30300' then 'Discount Golf World'
when '30355' then 'DSI Systems'
when '30360' then ' eBags'
when '30455' then ' Petra'
when '30475' then 'Sears'
when '30575' then 'ShoeBuy.com'
when '30585' then 'ShoppersChoice.com'
when '30825' then ' Unbeatable'
when '30830' then 'Mercent'
when '30850' then 'Premco'
when '70000' then 'Koinz'
else merchant_id
end
,count(*) as count from order_line
where create_date<='2011-10-25' and create_date>='2011-06-01' and supplier_id='200' and var_id in('b2s_qa','B2S_LIVE' ) and order_status<>'11'
group by var_id, program_id, merchant_id
order by var_id, program_id, merchant_id

select merchant_id, name from merchant

猜你喜欢

转载自coco5012.iteye.com/blog/1748185
今日推荐