I have a MODE query that I am trying to reference in another query.
I have a query, Query1, which has two columns. A StableID appears multiple times in one column and there is variable text that occurs in the column next to it. I want to select the mode for the variable text (the most common value) and return it for another query.
If there is only one value, or if there are only two which are different (no mode value) then returning the first one encountered is fine.
My problem is that I want it done once for each StableID, not just once for the whole dataset.
Thanks for any help!
Code:
SELECT TOP 1 [Query1].[VariableText], [Query1].[StableID]
FROM [Query1]
GROUP BY [Query1].[VariableText], [Query1].[StableID]
ORDER BY Count([Query1].[VariableText]) DESC;
I have a query, Query1, which has two columns. A StableID appears multiple times in one column and there is variable text that occurs in the column next to it. I want to select the mode for the variable text (the most common value) and return it for another query.
If there is only one value, or if there are only two which are different (no mode value) then returning the first one encountered is fine.
My problem is that I want it done once for each StableID, not just once for the whole dataset.
Thanks for any help!
Last edited: