<% 'Set up the connection... SET CONN = Server.createObject("ADODB.Connection") CONN.open "Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("\") & "\data\NothingToIt.mdb;UID=;PWD=;" 'Set up the first recordset... SQL = "SELECT DISTINCT subscriber_zip FROM subscriber_tbl WHERE subscriber_zip <> '00000';" SET RS = Server.CreateObject("ADODB.Recordset") RS.OPEN SQL, Conn, 1 rs.movefirst 'Now display the total number of records... SQL = "SELECT subscriber_id FROM subscriber_tbl WHERE subscriber_zip <> '00000' ORDER BY subscriber_zip;" SET RStotalcount = Server.CreateObject("ADODB.Recordset") RStotalcount.OPEN SQL, Conn, 1 rs.movefirst TotalCount = rstotalcount.recordcount response.write "

Total Number of Records: " & TotalCount & "

" RStotalcount.close SET RStotalcount=NOTHING 'Create a multi-dimensional array... DIM zipstats() REDIM zipstats(TotalCount, 2) 'our array data will be ZIPCODE, NUMBERFOUND, PERCENTAGE 'Create a new recordset... TemporaryCounter = 0 response.write "" response.write "" While Not RS.EOF 'open an new recordset searching only for the first zip code SQL = "SELECT subscriber_id FROM subscriber_tbl WHERE subscriber_zip ='"&RS("subscriber_zip")&"';" SET RSzip = server.createobject("ADODB.recordset") RSzip.OPEN SQL, CONN, 1 TempZipCount = RSzip.recordcount RSzip.close SET RSzip = NOTHING zipstats(TemporaryCounter, 0) = Left(RS("subscriber_zip"),5) zipstats(TemporaryCounter, 1) = CINT(TempZipCount) zipstats(TemporaryCounter, 2) = (CINT(TempZipCount)/CINT(totalcount)) Response.write "" TemporaryCounter = TemporaryCounter + 1 RS.movenext Wend Response.write "
Zip Code#% Where's This?
"& zipstats(TemporaryCounter, 0) & "" & zipstats(TemporaryCounter, 1) & "" & Round((zipstats(TemporaryCounter, 2)*100),2) & "?
" 'Now we are going to get the top five zip codes out... 'Cleanup... RS.close conn.close set rs = nothing set conn = nothing %>