sql statement (order by)

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: Mike
Date:  
Subject: sql statement (order by)
I found that out right after I posted. I now realize
that I shouldn't change the subject line of a post
(fixed ->....) so that I don't waste everyone's time :-)

Unfortunately, I can't change the datatype on this column.
I found out that all I had to do (for now) is preface
the column in the order by clause with '0+' (that's a zero),
and it worked as expected.

Thanks for everyone's help.

v/r
Mike


On Thu, May 30, 2002 at 08:17:28PM -0700, wrote:
It depends on the column's datatype.
If the column is an integer type then you'll have to use
'order by <col_name> descending'
This will produce:
1000
20
10
2

If the column is varchar (or char), the results you provided below would be
the result of an
ascending order by statement. The string '1000' comes after the string '10'
From the look of your output, it appears that the column is a varchar type.
To order it numerically, you'll have to convert the data to numeric within
the select statement.
The syntax for this will depend on the database you're using.

Hope this helps,
Peter

At 5/30/02 09:50 AM , you wrote:
>A bit off topic, but I thought someone could
>throw it out quick:
>
>I have a select statement that grabs a bunch of
>info from one table. One column has numbers
>in it representing Potential Revenue. I am trying
>to order my query by this column but I do not get the results
>i want. The order by just orders it by the first number.
>
>For instance
>
>10
>1000
>20
>2
>
>I want 1000 to be first and then descend from there.
>
>I have done this before but it is quite a bit like
>forgeting how to spell "the"!
>
>
>v/r
>Mike
>________________________________________________
>See http://PLUG.phoenix.az.us/navigator-mail.shtml if your mail doesn't
>post to the list quickly and you use Netscape to write mail.
>
>PLUG-discuss mailing list -
>http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss


________________________________________________
See http://PLUG.phoenix.az.us/navigator-mail.shtml if your mail doesn't post to the list quickly and you use Netscape to write mail.

PLUG-discuss mailing list -
http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss