create table t2 (user_id integer not null, timestamp datetime);
insert into t2 values (1, sysdate());
insert into t2 values (2, sysdate());
insert into t2 values (1, sysdate());
insert into t2 values (3, sysdate());
insert into t2 values (4, sysdate());
insert into t2 values (4, sysdate());
select u.gender as gender, count(distinct u.id) as dist_count, (count(distinct u.id)/5*100) as percentage from t1 u, t2 l where l.user_id = u.id group by u.gender;
select u.gender as gender, count(distinct u.id) as dist_count, (count(distinct u.id)/5*100) as percentage from t1 u, t2 l where l.user_id = u.id group by u.gender;