Professional Web Applications Themes

How to sort numerically? - MySQL

Hi, Could somebody please help me? I use the following SQL command to take the data and then sorts it: $querystr = "select ID,Name,Description,PictureURL,InformationURL,Rate ,10_Min,20_Min,Connect from $Table_Name order by 10_Min desc,Rate asc,Connect asc"; $sth = &sql($querystr); For some reason the sorted results look like this (field 10_Min): 526 412 135 1342 125 95 Why is 1342 not on top of this list and what do I need to do to change in the code to have 1342 on top? I assume right now it creates an ASCII order, and not a numeric one. Could somebody please tell me what I ...

  1. #1

    Default How to sort numerically?

    Hi,

    Could somebody please help me? I use the following SQL command to take the
    data and then sorts it:

    $querystr = "select
    ID,Name,Description,PictureURL,InformationURL,Rate ,10_Min,20_Min,Connect
    from $Table_Name order by 10_Min desc,Rate asc,Connect asc";
    $sth = &sql($querystr);

    For some reason the sorted results look like this (field 10_Min):

    526
    412
    135
    1342
    125
    95

    Why is 1342 not on top of this list and what do I need to do to change in
    the code to have 1342 on top? I assume right now it creates an ASCII order,
    and not a numeric one. Could somebody please tell me what I need to change
    in order to sort my results numerically?

    Thanks,

    Alex



    --
    Posted via a free Usenet account from [url]http://www.teranews.com[/url]

    Sergey Guest

  2. #2

    Default Re: How to sort numerically?

    >$querystr = "select
    >ID,Name,Description,PictureURL,InformationURL,Rat e,10_Min,20_Min,Connect
    >from $Table_Name order by 10_Min desc,Rate asc,Connect asc";
    >$sth = &sql($querystr);
    >
    >For some reason the sorted results look like this (field 10_Min):
    >
    >526
    >412
    >135
    >1342
    >125
    >95
    >
    >Why is 1342 not on top of this list and what do I need to do to change in
    >the code to have 1342 on top? I assume right now it creates an ASCII order,
    >and not a numeric one. Could somebody please tell me what I need to change
    >in order to sort my results numerically?
    Make a numeric expression out of it:
    ORDER BY 10_Min+0 desc, ...

    Gordon L. Burditt
    Gordon Burditt Guest

  3. #3

    Default Re: How to sort numerically?

    Sergey wrote:
    > Hi,
    >
    > Could somebody please help me? I use the following SQL command to take the
    > data and then sorts it:
    >
    > $querystr = "select
    > ID,Name,Description,PictureURL,InformationURL,Rate ,10_Min,20_Min,Connect
    > from $Table_Name order by 10_Min desc,Rate asc,Connect asc";
    > $sth = &sql($querystr);
    >
    > For some reason the sorted results look like this (field 10_Min):
    >
    > 526
    > 412
    > 135
    > 1342
    > 125
    > 95
    >
    > Why is 1342 not on top of this list and what do I need to do to change in
    > the code to have 1342 on top? I assume right now it creates an ASCII order,
    > and not a numeric one. Could somebody please tell me what I need to change
    > in order to sort my results numerically?
    >
    > Thanks,
    >
    > Alex
    >
    >
    >
    This isn't ASCII order, either. What's your table definition and what's
    the entire output of your query?

    --
    ==================
    Remove the "x" from my email address
    Jerry Stuckle
    JDS Computer Training Corp.
    [email]jstucklexattglobal.net[/email]
    ==================
    Jerry Stuckle Guest

  4. #4

    Default Re: How to sort numerically?

    > Make a numeric expression out of it:
    > ORDER BY 10_Min+0 desc, ...
    Thanks a lot. It worked!



    --
    Posted via a free Usenet account from [url]http://www.teranews.com[/url]

    Sergey Guest

Similar Threads

  1. Order A List Numerically
    By IamRobert in forum Coldfusion - Getting Started
    Replies: 3
    Last Post: August 19th, 03:00 PM
  2. Where is transform numerically?
    By parker@adobeforums.com in forum Adobe Photoshop Mac CS, CS2 & CS3
    Replies: 2
    Last Post: February 20th, 03:38 PM
  3. memory sort and disk sort
    By dusong in forum Informix
    Replies: 4
    Last Post: October 24th, 02:11 PM
  4. Replies: 1
    Last Post: September 9th, 07:16 AM
  5. Sort Ascending numerically?
    By Steve Thomas in forum Microsoft Access
    Replies: 1
    Last Post: July 9th, 08:14 AM

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
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139