In MySQL, how to generate percentage by DATE with compound group by? -


i have set of 3 queries return exact data like:

set @mydate = '2013-04-15';  set @dailycpu = (select sum(cputime) eojeot date(stoptime) = @mydate);  select usercode, date(stoptime) thedate,     sum(cputime) 'total cpu secs',     sum(elapsedtime) 'total elapsed secs',     (sum(cputime)/@dailycpu) * 100 pctcpu eojeot date(stoptime) = @mydate group usercode; 

this returns (i obfuscated real users)

usercode    thedate     total cpu secs  pctcpu fred        2013-04-15  35873067        0.4069 wilma       2013-04-15  26122714        0.2963 barney      2013-04-15  234689          0.0027 dino        2013-04-15  3284851116      37.2593 pebbles     2013-04-15  48108320        0.5457 bambam      2013-04-15  23671548        0.2685 kazoo       2013-04-15  284847          0.0032 

i trying put single query can add group of mydate.

basically, want sum cputime day particular user , show percentage of total cpu time day.

a snippet of table like:

usercode varchar(17) cputime bigint(20) stoptime datetime 

i have looked @ self joins trying join sum(cputime) a.date = b.date, did not work.

i thought self join posts read on se cannot find case factors in compound group (usercode, date(stop time) ).


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -