Thread: Case statement

    #1
  1. No Profile Picture
    Registered User
    ASP Explorer (0 - 99 posts)

    Join Date
    Apr 2012
    Posts
    2
    Rep Power
    0

    Case statement


    i need to display when code=10 then delqdays has to be greater than 30 else dont display

    I used
    select * from abc WHERE DelqDays >=( CASE WHEN IN (10) THEN '30' END )

    Plz help
  2. #2
  3. No Profile Picture
    Contributing User
    ASP Discoverer (100 - 499 posts)

    Join Date
    Aug 2008
    Posts
    454
    Rep Power
    167
    Originally Posted by ak99
    i need to display when code=10 then delqdays has to be greater than 30 else dont display

    I used
    select * from abc WHERE DelqDays >=( CASE WHEN IN (10) THEN '30' END )

    Plz help
    Code:
    select * from abc WHERE  DelqDays >= 30 AND code =10
  4. #3
  5. No Profile Picture
    Registered User
    ASP Explorer (0 - 99 posts)

    Join Date
    Apr 2012
    Posts
    2
    Rep Power
    0
    Originally Posted by Krandor
    Code:
    select * from abc WHERE  DelqDays >= 30 AND code =10
    Thanks for your help
    I think there is some misunderstanding,,it does not have filter on anything but except when code=10,,so it diplays everything when code is something else besides 10 but when code=10,,then delqdays has to be equal or greater than 30.
  6. #4
  7. Contributing User
    ASP Skiller (1500 - 1999 posts)

    Join Date
    Mar 2005
    Location
    Columbus, OH
    Posts
    1,592
    Rep Power
    278
    try that
    select * from abc WHERE 'Y' = case
    when code = 10 then case when delqdays =>30 then
    else 'N' end
    else 'Y' end
    GK
    __________________________________________________ _____
    if you found this post is useful click Give Rep button (bottom side on this reply ) and agree
  8. #5
  9. No Profile Picture
    Registered User
    ASP Explorer (0 - 99 posts)

    Join Date
    Mar 2012
    Location
    USA
    Posts
    75
    Rep Power
    0
    You can make nested case where

    SELECT CASE WHEN code = 10 THEN delqdays =>30

    else "N" end

Similar Threads

  1. Help with Select Case...
    By Bigced in forum ASP Development
    Replies: 9
    Last Post: January 11th, 2006, 09:07 AM
  2. My edit case statement doesn't work - again!!
    By YoungAngus in forum ASP Development
    Replies: 9
    Last Post: October 3rd, 2005, 07:25 AM
  3. only the 'delete' case statement works
    By YoungAngus in forum ASP Development
    Replies: 6
    Last Post: September 30th, 2005, 08:31 AM
  4. ASP: Unique random case statement
    By PupChow in forum Code Bank
    Replies: 2
    Last Post: November 15th, 2004, 09:52 AM
  5. SQL Statement Case selection...
    By plasma800 in forum SQL Development
    Replies: 1
    Last Post: May 4th, 2004, 05:13 AM

IMN logo majestic logo threadwatch logo seochat tools logo