Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2006
    Posts
    4

    Unanswered: How to get the correct Return_Amt from a table?

    Please can anyone help me?

    Table Name: tableSTK
    ItemID varchar(8)
    ItemDesc varchar(100)
    Price money

    Table Name: tableABC
    ItemID varchar(8)
    ConditionAmt money
    Return_Amt money

    The ConditionAmt and Return_Amt in the tableABC can be some other values
    based on the ItemID.

    Here is the sample with different values.

    ItemID ItemDesc Price
    04400110 A4 Paper 30.00
    08800220 Bic Pen 5.0 20.00

    ItemID ConditionAmt Return_Amt
    04400110 100.00 28.50
    04400110 200.00 27.00
    04400110 300.00 25.50
    08800220 50.00 19.00
    08800220 80.00 18.00
    08800220 150.00 15.00
    08800220 200.00 14.00

    I need a query to get the correct value from the Return_Amt based on the ConditionAmt of a
    total purchase amt on the particular ItemID.

    Examples
    A.
    John have a total purchase amt of 105.00.
    When he purchase ItemID 04400110 while total purchase amt is more than ConditionAmt 100.00
    and below 200 and below 300 the Return_Amt is 28.50 as SellingPrice.

    B.
    John have a total purchase amt of 250.00.
    When he purchase ItemID 04400110 while total purchase amt is more than ConditionAmt 200.00
    and below 300 the Return_Amt is 27.00 as SellingPrice.

    C.
    John have a total purchase amt of 400.00.
    When he purchase ItemID 04400110 while total purchase amt is more than ConditionAmt 300.00
    the Return_Amt is 28.50 as SellingPrice.

    D.
    John have a total purchase amt of 50.00.
    When he purchase ItemID 04400110 while total purchase amt is less than ConditionAmt 100.00
    therefore the ItemID 04400110 Price 30.00 as SellingPrice.

    E.
    Mary have a total purchase amt of 95.00.
    When she purchase ItemID 08800220 while total purchase amt is more than ConditionAmt 80.00
    and below 150 and below 200 the Return_Amt is 18.00 as SellingPrice.

  2. #2
    Join Date
    Feb 2008
    Location
    Japan
    Posts
    3,483
    I couldn't understand why SellingPrice of Example C was 28.50.

  3. #3
    Join Date
    Jun 2006
    Posts
    4
    Sorry for my mistake, the SellingPrice should be 25.50.

  4. #4
    Join Date
    Jun 2006
    Posts
    4
    Thanks everyone of you for trying to help.

    I have already got the solutions that solved my problems.

Posting Permissions

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