Most popular values in a recordset

E

Eddie

Hi
I am trying to soleve the following problem using an asp recordset (connects
to sql)
A column in the recordset contains integers between 1 and 5. I am trying to
find a way of concluding which integer is the most common, then the second
most common, then the third. (In the event of a tie, the higher integer
'wins'). Hence if in the record set there were 5 1s, 4 2s, 7 3s, 1 4 and 5
5s the output would be Most popular = 7, send most popular = 1 and third most
popular = 5. I am familiar with rhe recordset objects ie looping through the
records etc

Eddie
 
P

Patrice

It would be easier to just issue a SQL request such as :

SELECT Value, COUNT(*) FROM MyTable ORDER BY 2 DESC,Value DESC

Else you could loop the recordset and store the count in an array....
 
P

Patrice

I fogort the GROUP BY Value clause...

--

Patrice said:
It would be easier to just issue a SQL request such as :

SELECT Value, COUNT(*) FROM MyTable ORDER BY 2 DESC,Value DESC

Else you could loop the recordset and store the count in an array....
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top