SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Sep 2007
    Posts
    38
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to compare 2 colums of same table to get result from 3rd column of same table

    Heloo All,

    with reference to following table now i want to check the 2 values ie
    "order" and "orderval" in the range then i want that respective shipcharge for hat min and max values
    eg.
    say my minvalue(order) is 12.45 and maxvalue(total) is 50.00 then query should return me Shipcharge as 11

    and if

    say my minvalue(order) is 251.12. and maxvalue(total) is 280.12then query should return me Shipcharge as 40.95


    Id orderval total Shipcharg addeddate

    1 Under 50.00 11 2008-03-31 15:17:45.217
    2 50.01 75 16.95 2008-03-31 15:19:01.107
    3 75.01 100 20.95 2008-03-31 15:19:14.077
    4 100.01 150 25.95 2008-03-31 15:19:25.763
    5 150.01 200 30.95 2008-03-31 15:19:38.250
    6 200.01 250 34.95 2008-03-31 15:19:46.480
    8 Over 250.00 40.95 2008-03-31 15:20:04.547


    I tried it so many ways but not getting the required ouput
    Please provide me solution as soon as possible

    Thanks in advance

  2. #2
    SitePoint Zealot
    Join Date
    Mar 2005
    Posts
    162
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try using a calculated column, or do it in your SQL Query with a case statement.

    I would choose to do it in my SQL Query b/c its just a bit easier IMO.
    Web Application Development & Maintenance


Bookmarks

Posting Permissions

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