Ok.. So basically your statement is re-defining "thefield" as an integer if isNumeric returns 1. Else 0 returning thefield as it's original data type.
ORDER BY CASE WHEN IsNumeric(thefield)=1 THEN CAST(thefield AS INT) ELSE 0 END,thefield Very cool! Thanks for the lesson, I have never used WHEN, THEN, ELSE, END in SQL. -----Original Message----- From: Andy Matthews [mailto:[EMAIL PROTECTED] Sent: Thursday, January 25, 2007 9:51 AM To: CF-Talk Subject: RE: SQL order by Case isn't a function. It's a flow control statement. Just like doing a cfswitch statement in CF. -----Original Message----- From: Chad Gray [mailto:[EMAIL PROTECTED] Sent: Thursday, January 25, 2007 8:52 AM To: CF-Talk Subject: RE: SQL order by Thanks Jim! That works great for me! I will have to look up CASE, I am not familiar with that function. Thanks again! -----Original Message----- From: Jim Wright [mailto:[EMAIL PROTECTED] Sent: Thursday, January 25, 2007 9:26 AM To: CF-Talk Subject: Re: SQL order by Chad Gray wrote: > > I cannot switch it to an integer field because there will be some text also. > > Any way to accomplish this? > maybe something like... SELECT thefield FROM foo ORDER BY CASE WHEN IsNumeric(thefield)=1 THEN CAST(thefield AS INT) ELSE 0 END,thefield That should put the text fields at the beginning, sorted alphabetically, and the numeric fields at the end, sorted numerically. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Upgrade to Adobe ColdFusion MX7 Experience Flex 2 & MX7 integration & create powerful cross-platform RIAs http:http://ad.doubleclick.net/clk;56760587;14748456;a?http://www.adobe.com/products/coldfusion/flex2/?sdid=LVNU Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:267611 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

