sql statement (order by)
plug-discuss@lists.plug.phoenix.az.us
plug-discuss@lists.plug.phoenix.az.us
Thu, 30 May 2002 20:17:28 -0700
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 - PLUG-discuss@lists.plug.phoenix.az.us
>http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss