Percentage Distribution

Frequency distribution with percentages

Requires two-passes over the data

create or replace view totname (totname_total)
as
(select count(*)
   from name
  where name_seriesno = name_now(name_id));

select person_gender "sex",
       count(*) "count",
       round(100*count(*)/totname_total,0) "pct"
  from person,
       name,
       totname
 where name_seriesno = name_now(name_id)
   and person_id = name_id
 group by person_gender,
       totname_total
 order by 1;

sex      count        pct
--- ---------- ----------
F            3         50
M            2         33
             1         17
    ---------- ----------
sum          6        100


Top Next