summaryrefslogtreecommitdiff
path: root/mysql-test
diff options
context:
space:
mode:
authormonty@hundin.mysql.fi <>2002-06-09 15:41:19 +0300
committermonty@hundin.mysql.fi <>2002-06-09 15:41:19 +0300
commit2c274c64b9f42c9507b96205cf5e7a7f2a601253 (patch)
treea0bd5c2fd8256b0392b23ba6fde14ae3b17e4f26 /mysql-test
parent01094b1391fed749a23bd6268765d7b969e6404d (diff)
downloadmariadb-git-2c274c64b9f42c9507b96205cf5e7a7f2a601253.tar.gz
Bug fix for complicated GROUP BY ... ORDER BY query.
Fixed problem in access rights testing (from last patch)
Diffstat (limited to 'mysql-test')
-rw-r--r--mysql-test/r/group_by.result31
-rw-r--r--mysql-test/t/group_by.test37
2 files changed, 16 insertions, 52 deletions
diff --git a/mysql-test/r/group_by.result b/mysql-test/r/group_by.result
index d990760d39b..0ec1c03c467 100644
--- a/mysql-test/r/group_by.result
+++ b/mysql-test/r/group_by.result
@@ -375,38 +375,17 @@ hijklm 2
DROP TABLE t1;
drop table if exists t1;
create table t1 (One int unsigned, Two int unsigned, Three int unsigned, Four int unsigned);
-insert into t1 values (1,2,1,4);
-insert into t1 values (1,2,2,4);
-insert into t1 values (1,2,3,4);
-insert into t1 values (1,2,4,4);
-insert into t1 values (1,1,1,4);
-insert into t1 values (1,1,2,4);
-insert into t1 values (1,1,3,4);
-insert into t1 values (1,1,4,4);
-insert into t1 values (1,3,1,4);
-insert into t1 values (1,3,2,4);
-insert into t1 values (1,3,3,4);
-insert into t1 values (1,3,4,4);
+insert into t1 values (1,2,1,4),(1,2,2,4),(1,2,3,4),(1,2,4,4),(1,1,1,4),(1,1,2,4),(1,1,3,4),(1,1,4,4),(1,3,1,4),(1,3,2,4),(1,3,3,4),(1,3,4,4);
select One, Two, sum(Four) from t1 group by One,Two;
One Two sum(Four)
1 1 16
1 2 16
1 3 16
-drop table if exists t1;
-drop table if exists t1,t2;
+drop table t1;
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());
+insert into t1 values (NULL, 'M'), (NULL, 'F'),(NULL, 'F'),(NULL, 'F'),(NULL, 'M');
+create table t2 (user_id integer not null, date date);
+insert into t2 values (1, '2002-06-09'),(2, '2002-06-09'),(1, '2002-06-09'),(3, '2002-06-09'),(4, '2002-06-09'),(4, '2002-06-09');
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
diff --git a/mysql-test/t/group_by.test b/mysql-test/t/group_by.test
index 09a2bee0d0c..0c9197febb5 100644
--- a/mysql-test/t/group_by.test
+++ b/mysql-test/t/group_by.test
@@ -284,35 +284,20 @@ INSERT INTO t1 values ('hij','klm');
SELECT CONCAT(a, b),count(*) FROM t1 GROUP BY 1;
DROP TABLE t1;
drop table if exists t1;
+
+#
+# Test problem with ORDER BY on a SUM() column
+#
+
create table t1 (One int unsigned, Two int unsigned, Three int unsigned, Four int unsigned);
-insert into t1 values (1,2,1,4);
-insert into t1 values (1,2,2,4);
-insert into t1 values (1,2,3,4);
-insert into t1 values (1,2,4,4);
-insert into t1 values (1,1,1,4);
-insert into t1 values (1,1,2,4);
-insert into t1 values (1,1,3,4);
-insert into t1 values (1,1,4,4);
-insert into t1 values (1,3,1,4);
-insert into t1 values (1,3,2,4);
-insert into t1 values (1,3,3,4);
-insert into t1 values (1,3,4,4);
+insert into t1 values (1,2,1,4),(1,2,2,4),(1,2,3,4),(1,2,4,4),(1,1,1,4),(1,1,2,4),(1,1,3,4),(1,1,4,4),(1,3,1,4),(1,3,2,4),(1,3,3,4),(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;
+drop table t1;
+
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());
+insert into t1 values (NULL, 'M'), (NULL, 'F'),(NULL, 'F'),(NULL, 'F'),(NULL, 'M');
+create table t2 (user_id integer not null, date date);
+insert into t2 values (1, '2002-06-09'),(2, '2002-06-09'),(1, '2002-06-09'),(3, '2002-06-09'),(4, '2002-06-09'),(4, '2002-06-09');
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;