Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

majority value

Status
Not open for further replies.

romnew

Programmer
Feb 27, 2002
44
ZA
Hi ye programmers,
I need to find the majority value of a certain field of the last ten records within a table. Finding the last ten records is OK but it totally escapes me how to find the majority value of the field just using a query or code.Please help
Thanks.
 
And majority value is what? Robert Berman
Data Base consultant
Vulcan Software Services
thornmastr@yahoo.com
 
Thanks for asking
The ten records would typicaly reflect ie:1=8;2=8
3=8;4=12;5=12;6=12;7=5;8=4;9=8;10=12.The majority value of these numbers is 12. How do I get it?
Thanks for looking at the problem.
Romnew
 
Basically you need to count each value and select the value with the highest count. This can be done with queries or with code. You can experiment with count queries by creating a query and in design view clicking the icon with the greek sigma sign on it (looks like a foreign E). The column you want to count on change Group By to Count.

Your logic should face the possibility that there could be a tie and that all 10 values might be different so that no majority exists.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top