HI WELCOME TO SIRIS

Using CASE to create new column based on specific data in a column

Leave a Comment
SELECT field1,
       field2,
       field3,
       fieldname = CASE [field4] 
        WHEN '9' THEN 'Semi Trailer'
        WHEN '7' THEN 'Pole Trailer'
        WHEN '6' THEN 'Other'
        WHEN '5' THEN 'Motor Carrier'
        WHEN '3' THEN 'Full Trailer'
        WHEN '2' THEN 'Dolly Converter'
        WHEN '14' THEN 'Intermodal Chassis'
        WHEN '12' THEN 'Van'
        WHEN '11' THEN 'Truck Tractor'
        WHEN '10' THEN 'Straight Truck'
        ELSE 'Invalid'
       END
FROM [dbo].[kansiris];

0 comments:

Post a Comment

Note: only a member of this blog may post a comment.