Mode Function, Like in Excel

Oswald_Cobblepot

Registered User.
Local time
Today, 09:44
Joined
Feb 28, 2002
Messages
11
Is there any way in Access to retrieve the mode (most frequent value) in a set of data. Excel has this function but I don't know if Access does.

Thanks
 
Where do I search for this reference?
 
Sorry I wasn't searching in the right place.

But, do you know if there is a way to get it to display the mode for not the entire table but for different (in my case) playerId's as in the totals box.

Thanks
 
Assuming the data are stored in the fields PlayerID and Score in table tblScore and you want to find the Mode of scores of each player, you can use two queries:

qryCount:-
SELECT PlayerID, Score, count(*) AS CountNum
FROM tblScore
GROUP BY PlayerID, Score
ORDER BY PlayerID, Score;


qryMode:-
SELECT PlayerID, Score AS [Mode of Score]
FROM qryCount
WHERE PlayerID & CountNum in (select PlayerID & max(CountNum) from qryCount group by PlayerID)
ORDER BY PlayerID, Score;


Run the second query.


Notice that
(1) Score can be a text field or a numeric field.

(2) If the scores of a player happen to be multi-modal, more than one row will be returned for that player.

If you want to return only one row for each player, you can create a total query based on qryMode to pull either the max(), min(), first() or last() of [Mode of Score]. Excel can't handle multi-modal and will return the first.
 

Users who are viewing this thread

Back
Top Bottom