mirror of
https://github.com/MariaDB/server.git
synced 2026-01-06 05:22:24 +03:00
fixed problem with distinct select with grouping and subqueries (BUG#7946)
This commit is contained in:
@@ -330,3 +330,12 @@ SELECT MIN(price) min, MAX(price) max, AVG(price) avg FROM (SELECT SUBSTRING( MA
|
||||
min max avg
|
||||
10.00 10.00 10
|
||||
DROP TABLE t1;
|
||||
create table t1 (a integer, b integer);
|
||||
insert into t1 values (1,4), (2,2),(2,2), (4,1),(4,1),(4,1),(4,1);
|
||||
select distinct sum(b) from t1 group by a;
|
||||
sum(b)
|
||||
4
|
||||
select distinct sum(b) from (select a,b from t1) y group by a;
|
||||
sum(b)
|
||||
4
|
||||
drop table t1;
|
||||
|
||||
@@ -214,3 +214,13 @@ CREATE TABLE `t1` ( `itemid` int(11) NOT NULL default '0', `grpid` varchar(15) N
|
||||
insert into t1 values (128, 'rozn', 2, now(), 10),(128, 'rozn', 1, now(), 10);
|
||||
SELECT MIN(price) min, MAX(price) max, AVG(price) avg FROM (SELECT SUBSTRING( MAX(concat(date_,";",price)), 12) price FROM t1 WHERE itemid=128 AND grpid='rozn' GROUP BY itemid, grpid, vendor) lastprices;
|
||||
DROP TABLE t1;
|
||||
|
||||
#
|
||||
# DISTINCT over grouped select on subquery in the FROM clause
|
||||
#
|
||||
create table t1 (a integer, b integer);
|
||||
insert into t1 values (1,4), (2,2),(2,2), (4,1),(4,1),(4,1),(4,1);
|
||||
select distinct sum(b) from t1 group by a;
|
||||
select distinct sum(b) from (select a,b from t1) y group by a;
|
||||
drop table t1;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user