Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 what does no match to case set it to?

Author  Topic 

chedderslam
Posting Yak Master

223 Posts

Posted - 2009-09-16 : 14:35:30
SELECT coverage = CASE
WHEN e.coverage = 'BI'
THEN 1
WHEN e.coverage = 'CL'
THEN 3
END,
rate_zip = CASE
WHEN e.driver_class IN ('300','301','302','303',
'304','400','401','402',
'403','404')
THEN '99200'
WHEN e.driver_class IN ('100','101','102')
THEN '99250'
WHEN e.driver_class IN ('114','115','116','214',
'215','216','314','315',
'316','414','415','416')
THEN '99600'
WHEN d.business_use = 'Y'
AND e.driver_class NOT IN ('100','101','102','300',
'301','302','303','304',
'400','401','402','403',
'404')
THEN '99300'
ELSE '99100'
END,
insurer_vehicles = CASE
WHEN e.cancel_code IN ('CR','UD','UI','UL',
'UV','UW','RW')
THEN Count(e.vehicle_number)
END,
nonpay_vehicles = CASE
WHEN e.cancel_code IN ('AD','AP','AR','FN',
'NA','ND','NF','NI',
'NP','NS')
THEN Count(e.vehicle_number)
END,
insured_vehicles = CASE
WHEN e.cancel_code IN ('II','IR')
THEN Count(e.vehicle_number)
END

For the last three columns, if the in list is not matched, what will the column be set to? Null?

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-09-17 : 04:58:35
Yes - NULL.
You can try this:
select
case
when 1=2 then '?'
end as test



No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page
   

- Advertisement -