1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

A bug fix and test case for a bug that appears in quereis where there

is a GROUP BY a column that is not NOT NULL and ORDER BY is done by
another column.

Even better fix would be to make a separate function for this.
This commit is contained in:
unknown
2002-06-08 20:02:49 +03:00
parent 15c99d52a2
commit ec09d2e5a8
3 changed files with 48 additions and 3 deletions

View File

@ -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;

View File

@ -299,3 +299,20 @@ insert into t1 values (1,3,3,4);
insert into t1 values (1,3,4,4);
select One, Two, sum(Four) from t1 group by One,Two;
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;
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;
drop table t1,t2;