SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: How to sort ?

  1. #1
    SitePoint Evangelist Tapan's Avatar
    Join Date
    May 2005
    Location
    India
    Posts
    564
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    How to sort ?

    Hello,

    I have a varchar field in which there is text like:

    100 x 150
    50 x 25
    76 x 51

    I want to sort it. But when i put ORDER BY it then shows 100 first then 50 and then 76

    How to make it so it shows 50, 76 and then 100 ?

    Thanks.

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,340
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    use two columns, and make them numeric

    VARCHAR sorts alphabetically, starting at the leftmost character
    rudy.ca | @rudydotca
    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
  •