IF condition in SELECT statement

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • missshaikh
    New Member
    • Mar 2007
    • 43

    IF condition in SELECT statement

    We have a customer fee table. I am trying to make a table that calculates based on the type of charge.

    If Memo = 'C' then charge should be Commission * Rate
    ELSE it should be 0.

    I thought I can do the following…

    Code:
    SELECT Customer, Commission, Fee, IIF(Memo='C',(Commission*Rate),0) as CommissionCharge, IIF(Memo2='C',(Fee*Rate),0) as CommissionFee
    FROM Customer_Charge;
    But this doesn't work. Do you have any suggestions?

    Thanks,
  • ck9663
    Recognized Expert Specialist
    • Jun 2007
    • 2878

    #2
    SQL Server use CASE...WHEN...E ND instead of IIF.

    Good Luck!!!

    ~~ CK

    Comment

    Working...