Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2011
    Posts
    17

    Unanswered: The lowest value between two columns

    Hi.



    SELECT

    @AppId AS Application_Id
    , MB.POLICY_ID AS Policy_Id
    , MH.BFN_CHG_DATEAS Date_Of_Disinvestment
    , AD.X_INVEST_AMT AS Original_Investment_Value
    , MB.TOTAL_AMOUNT AS Encashment_Value
    , WH.TOT_COMMISSION AS Top-Up_Commission



    FROM: I select from lot of table, as specified from my select statement

    My output:
    AppId PolicyId Date_Of_DisIn Original_Inv Encashment_Value Top-Up_Commision ???
    1-1-1; 1000000; Jan-01-12; 2882.07; 3312.00; 2306; ??


    My Aliases returns just one values, of which that's what I am expecting, so I need to make a comparison between Original_Investment_Value and (Encashment_Value + Top-Up_Commision), and return the lowest value

    Please help
    Last edited by stahorse1; 09-14-12 at 04:22.

  2. #2
    Join Date
    Nov 2011
    Posts
    17
    Can I clarify my problem

    My Aliases returns just one values, of which that's what I am expecting, so I need to take just those values and compare them and return the last column, of which is the lowest value from my comparison.

    My output:
    AppId PolicyId Date_Of_DisIn Original_Inv Encashment_Value Top-Up_Commision ???
    1-1-1 1000000; Jan-01-12; 2882.07 ; 3312.00 ; 2306; ??

    Now my last row has to be comparison between Original_Inv and (Encash_Value + Top-Up_Commision), and return the

  3. #3
    Join Date
    Apr 2012
    Posts
    213
    Hi,

    Try:

    Code:
    case when AD.X_INVEST_AMT < MB.TOTAL_AMOUNT + WH.TOT_COMMISSION
        then AD.X_INVEST_AMT
        else MB.TOTAL_AMOUNT + WH.TOT_COMMISSION
    end as LowestValue
    Hope this helps.

Posting Permissions

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