Results 1 to 3 of 3

Thread: Need help sql case statement!!!!

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2000
    Location
    bebenia, PA, USA
    Posts
    241
    is there a way to do this with a case statement?


    update #totals
    set cutoff = '3:00pm'
    where id in (14,15)

    update #totals
    set cutoff = '1:00pm'
    where id in (16)

    update #totals
    set cutoff = '12:00pm'
    where id in (17,18,19,20)

    update #totals
    set cutoff = '9:00am'
    where id in (21)

    update #totals
    set cutoff = '2:40pm'
    where id in (22)

  2. #2
    Lively Member
    Join Date
    Dec 1999
    Location
    Karlsruhe, Germany
    Posts
    122
    Yes (MS SQL Server 7.0):

    UPDATE #totals set cutoff =
    CASE id
    when 14 then '3:00pm'
    when 15 then '3:00pm'
    when 16 then '1:00pm
    ...
    END

    That's it!

    Roger

  3. #3
    Guest
    case is available in SQL Server 6.5 too!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width