Hi Jim, you can try
<cfquery name="getZip" datasource="#request.maindsn#"> SELECT DISTINCT zipcode, count(zipcode) as zipnum FROM tblSurvey WHERE state = '#URL.state#' GROUP BY zipcode ORDER BY count(zipcode), zipcode </cfquery> or depending on your database <cfquery name="getZip" datasource="#request.maindsn#"> SELECT DISTINCT zipcode, count(zipcode) as zipnum FROM tblSurvey WHERE state = '#URL.state#' GROUP BY zipcode ORDER BY 2, zipcode </cfquery> Chuck Rodgers At 01:31 PM 1/24/02 -0500, you wrote: >I've inherited a table with the usual name, address, city, state, zip. > >I've been asked if I can sort the list via ZIP code and have the >output sorted by the zip code - most popular first, and I'm stumped. > >So far I've got this: > ><cfquery name="getZip" datasource="#request.maindsn#"> > SELECT DISTINCT zipcode, count(zipcode) as zipnum > FROM tblSurvey > WHERE state = '#URL.state#' > GROUP BY zipcode > ORDER BY zipcode ></cfquery> > >This gives me the correct output but sorted incorrectly (I'd like to >sort by the zipnum (QTY): > >ZIP QTY >------------ >12345 (1) >23452 (1) >23454-1234 (1) >27612 (4) >34562 (1) >55555 (1) > >I've dug through the archives, and the Macromedia forums but haven't >hit anything yet. If I try to GROUP or ORDER BY the zipnum alias I >get an error. > >Any ideas? Am I overcomplicating this and missing something simple? > >Thanks much! >Jim > ______________________________________________________________________ Dedicated Windows 2000 Server PIII 800 / 256 MB RAM / 40 GB HD / 20 GB MO/XFER Instant Activation � $99/Month � Free Setup http://www.pennyhost.com/redirect.cfm?adcode=coldfusiona FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/[email protected]/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

