Using case and Like

  • I am trying to use case and Like in my select statement as follows:

    select tag, a, b, ADG = case tag when like'Y%' then '2' else '1' end from

    (SELECT id, Weight, weigh_day FROM Cow_data

    can't seem to get this working, please help!

  • troyrowlands (9/30/2009)


    I am trying to use case and Like in my select statement as follows:

    select tag, a, b, ADG = case tag when like'Y%' then '2' else '1' end from

    (SELECT id, Weight, weigh_day FROM Cow_data

    can't seem to get this working, please help!

    select tag, a, b, ADG = case when tag like 'Y%' then '2' else '1' end from

    (SELECT id, Weight, weigh_day FROM Cow_data

    ____________________________________________________

    Deja View - The strange feeling that somewhere, sometime you've optimised this query before

    How to get the best help on a forum

    http://www.sqlservercentral.com/articles/Best+Practices/61537
  • Many thanks, it is now working

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply