Skip to content

Instantly share code, notes, and snippets.

@tomill
Created April 5, 2012 01:08
Show Gist options
  • Save tomill/2307102 to your computer and use it in GitHub Desktop.
Save tomill/2307102 to your computer and use it in GitHub Desktop.
select round(avg(sec)) as avg, max(sec) as max from foo;
select sec as mode from (select sec, count(*) as c from foo group by sec ) as t order by c desc limit 1;
select @mednum := floor(count(*) / 2) from foo;
set @rownum = 0;
select sec as median from (select @rownum := @rownum + 1 as rownum, sec from foo order by sec) as t where rownum = @mednum;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment