473,405 Members | 2,167 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Most popular values in a recordset

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
Dec 13 '05 #1
2 1735
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....

--

"Eddie" <Ed***@discussions.microsoft.com> a écrit dans le message de
news:6E**********************************@microsof t.com...
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

Dec 13 '05 #2
I fogort the GROUP BY Value clause...

--

"Patrice" <no****@nowhere.com> a écrit dans le message de
news:Ok*************@TK2MSFTNGP12.phx.gbl...
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....

--

"Eddie" <Ed***@discussions.microsoft.com> a écrit dans le message de
news:6E**********************************@microsof t.com...
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


Dec 13 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Modest Marsupial | last post by:
What is the DAO method of allowing a recordset to have null values? Thanks, marie
4
by: James | last post by:
Hi all, I have recently been assigned the responsibility to conduct a survey for the most popular programming language. I understand that most of will program in C++ alone, but I am conducting...
3
by: manny | last post by:
Problem: how to have query show only most recent records. This query shows all exams in 2005 for particular individual (grades not shown to avoid embarrassing John Slacker!): SELECT...
0
by: Lordwillin | last post by:
Hi, I am doing a database for my MIS Project and my memory of access is quite outdated. In one of my tables i have a field by the name of CFC, which holds flight info for my database e.g. AA-432...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.