[EMAIL PROTECTED] wrote:
"Igor Tandetnik" <[EMAIL PROTECTED]> wrote:
Tim Martin wrote:
Does anyone have any working solutions for calculating the mode of a
set of values in SQLite?
I'm not exactly sure what "mode" is. From your examples, it seems
you want to get an element that occurs most often. This should do it:
select salary, count(*) occurs
from payroll
group by salary
having occurs=
(select count(*) c from payroll group by salary order by c desc
limit 1)
Or how about:
select salary, count(*) frequency
from payroll
group by salary
order by frequency
limit 1;
This does not quite do the right thing if there are two or more values
with equal frequency.
Igor Tandetnik