All pastes #220745 Raw Edit

Someone

public text v1 · immutable
#220745 ·published 2006-10-25 09:30 UTC
rendered paste body
I'v got this query:

select type, count(*)
from
(
select
if(c_dur < 50,
  '50',
  if (c_dur between 50 and 59,
    '60',
    'Other'
  )
) as type
from calltable
where calltime between '2006-10-23 0:0:0' and '2006-10-23 23:59:59'
) as main
group by type
WITH ROLLUP


and get this result:

type, count(*)
'50', 302144
'60', 6813
'Other', 107279
'', 416236

Is there a way I can get percentages ?
Like this:

type, count(*), percent
'50', 302144, 72.5
'60', 6813, 1.6
'Other', 107279, 25.77
'', 416236, ''


Where percent is count(*) x 100 / total.