คำตอบ negitve case

  • 16 เมษายน 2555 12:19
     
     
        

    how do I do this in tsql?

        CASE tradeType not 'VANILLA' THEN banksidePremium END AS [BANK PREMIUM]

ตอบทั้งหมด

  • 16 เมษายน 2555 12:21
     
     คำตอบ มีโค้ด

    Nearly there, try...

    CASE WHEN TradeType <> 'VANILLA' THEN banksidePremium ELSE .... END AS [BANK PREMIUM]


    Blog: www.adathedev.co.uk

    • ทำเครื่องหมายเป็นคำตอบโดย Quantum Information 16 เมษายน 2555 12:23
    •  
  • 16 เมษายน 2555 12:21
    ผู้ตอบ
     
     คำตอบ
    CASE WHEN TradeType <>'VANILA' THEN ..... END FROM tb'

    Best Regards, Uri Dimant SQL Server MVP http://dimantdatabasesolutions.blogspot.com/ http://sqlblog.com/blogs/uri_dimant/


  • 16 เมษายน 2555 12:23
     
     คำตอบ มีโค้ด

    Try:

    CASE WHEN tradeType <> 'VANILLA' THEN banksidePremium END AS [BANK PREMIUM]

    Alternatively:

    CASE tradeType WHEN 'VANILLA' THEN NULL ELSE banksidePremium END AS [BANK PREMIUM]


    Dan Guzman, SQL Server MVP, http://weblogs.sqlteam.com/dang/

  • 16 เมษายน 2555 12:24
     
     
    thx all :)
  • 16 เมษายน 2555 13:59
     
     

    for some reason this always returns false:

      CASE when tradeType <> 'VANILLA' THEN banksidePremium  END AS [BANK PREMIUM],


  • 16 เมษายน 2555 14:20
     
     

    encapsulate the else part also

    case when tradetype<>'VANILLA' then banksidepremium else <add the else part here> end as [Bank Premium]


    Thanks and regards, Rishabh , Microsoft Community Contributor