diff options
Diffstat (limited to 'mysql-test/r/group_by.result')
-rw-r--r-- | mysql-test/r/group_by.result | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/mysql-test/r/group_by.result b/mysql-test/r/group_by.result index aaa03f2668a..d990760d39b 100644 --- a/mysql-test/r/group_by.result +++ b/mysql-test/r/group_by.result @@ -393,3 +393,26 @@ One Two sum(Four) 1 2 16 1 3 16 drop table if exists t1; +drop table if exists t1,t2; +create table t1 (id integer primary key not null auto_increment, gender char(1)); +insert into t1 values(NULL, 'M'); +insert into t1 values(NULL, 'F'); +insert into t1 values(NULL, 'F'); +insert into t1 values(NULL, 'F'); +insert into t1 values(NULL, 'M'); +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; +gender dist_count percentage +F 3 60.00 +M 1 20.00 +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 order by percentage; +gender dist_count percentage +M 1 20.00 +F 3 60.00 +drop table t1,t2; |