SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Addict
    Join Date
    Jul 2007
    Posts
    223
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to Order By two price columns?

    Greetings,

    I have a table with two columns "AuctionPrice" and "BINPrice". Some Auctions also have a BINPrice too (Buy It Now Price).

    I need to sort by lowest and highest prices, very similar to how eBay does it. This is what I've gotten so far:
    Code:
    ORDER BY AuctionPrice DESC, BINPrice DESC
    This doesn't seem to be working. I have a feeling both price columns need to be combined somehow but I'm not sure.

    Let me know how this could be done.

    Thanks

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,014
    Mentioned
    53 Post(s)
    Tagged
    2 Thread(s)
    ORDER BY COALESCE(BINprice,AuctionPrice ) DESC
    r937.com | rudy.ca | Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Addict
    Join Date
    Jul 2007
    Posts
    223
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Awesome! Thanks a lot for the help.

    Kind regards

  4. #4
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,014
    Mentioned
    53 Post(s)
    Tagged
    2 Thread(s)
    so i made a lucky guess
    r937.com | rudy.ca | Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"


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
  •