Thanks Much Dave,

   Actually, I finally figured out that CAST(getJobs.accountID AS INT) is 
actually CAST(getJobs.accountID AS INTEGER) and it works fine.  But, your 
solution is interesting.

Thanks again,
Lewis







-----Original Message-----
From: Dave Phillips <[EMAIL PROTECTED]>
To: cf-newbie <[email protected]>
Sent: Tue, 21 Oct 2008 5:37 pm
Subject: RE: Numerical order of query results



Lewis,
Have you tried 
ORDER BY convert(numeric(8),getJobs.accountID)  
Dave
-----Original Message-----
rom: Lewis Billingsley [mailto:[EMAIL PROTECTED] 
ent: Tuesday, October 21, 2008 4:29 PM
o: cf-newbie
ubject: Re: Numerical order of query results
Thanks.
ut, I got an error saying: Encountered "INT. Incorrect Select List, Unsupported 
ast type: AS
   The server is SQL Server, is that a problem?
ere is the query as I'm using it:
SELECT CAST(getJobs.accountID AS INT) accountID, getJobs.accountName, 
etJobs.SRep,
      COUNT(getJobs.JobN) as jTotal,
      SUM(getJobs.ESC1) as esTotal,
      SUM(getJobs.revTotal) as ttTotal
ROM getJobs
ROUP By accountID, getJobs.accountName, getJobs.SRep
AVING  SUM(getJobs.revTotal) #oper# #param#
RDER By accountID
/CFIF>

>The leading 0 is causing the problem.

Convert to a numeric type in the order by clause or alias the a casted
column and order by that:

SELECT yourColumns, CAST(AccountID AS INT) orderByAccountID
FROM yourTable
ORDER BY orderByAccountID

Adrian
Building a database of ColdFusion errors at http://cferror.org/

Hello,

I have a simple proble
m, but don’t know how to remedy it.  I have a query
that returns accountIDs among other things.  The query has an Order By
AccountID.  Everything goes fine if the Account Id is only 7 numbers like
0112345, but if the Account ID is 8 numbers as in 01103456, the latter
number (the 8digit  number), which is larger, will appear before any of the
seven digit numbers. I need it to appear in actual numerical order. Â How
can I handle the results of the query to do that, or how can I change the
query to assure numerical order?

Thanks,

Lewis



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f

Archive: 
http://www.houseoffusion.com/groups/cf-newbie/message.cfm/messageid:4068
Subscription: http://www.houseoffusion.com/groups/cf-newbie/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.15

Reply via email to