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
______________________________________________________________________
Why Share?
  Dedicated Win 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=coldfusionc
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

Reply via email to