Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mariadb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
3bd203d3
Commit
3bd203d3
authored
Jan 20, 2005
by
bell@sanja.is.com.ua
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed problem with distinct select with grouping and subqueries (BUG#7946)
parent
e05b028c
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
1 deletion
+20
-1
mysql-test/r/derived.result
mysql-test/r/derived.result
+9
-0
mysql-test/t/derived.test
mysql-test/t/derived.test
+10
-0
sql/sql_select.cc
sql/sql_select.cc
+1
-1
No files found.
mysql-test/r/derived.result
View file @
3bd203d3
...
@@ -330,3 +330,12 @@ SELECT MIN(price) min, MAX(price) max, AVG(price) avg FROM (SELECT SUBSTRING( MA
...
@@ -330,3 +330,12 @@ SELECT MIN(price) min, MAX(price) max, AVG(price) avg FROM (SELECT SUBSTRING( MA
min max avg
min max avg
10.00 10.00 10
10.00 10.00 10
DROP TABLE t1;
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;
mysql-test/t/derived.test
View file @
3bd203d3
...
@@ -214,3 +214,13 @@ CREATE TABLE `t1` ( `itemid` int(11) NOT NULL default '0', `grpid` varchar(15) N
...
@@ -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
);
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
;
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
;
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
;
sql/sql_select.cc
View file @
3bd203d3
...
@@ -1304,7 +1304,7 @@ JOIN::exec()
...
@@ -1304,7 +1304,7 @@ JOIN::exec()
curr_join
->
select_distinct
=
0
;
/* Each row is unique */
curr_join
->
select_distinct
=
0
;
/* Each row is unique */
curr_join
->
join_free
(
0
);
/* Free quick selects */
curr_join
->
join_free
(
0
);
/* Free quick selects */
if
(
select_distinct
&&
!
group_list
)
if
(
curr_join
->
select_distinct
&&
!
curr_join
->
group_list
)
{
{
thd
->
proc_info
=
"Removing duplicates"
;
thd
->
proc_info
=
"Removing duplicates"
;
if
(
curr_join
->
tmp_having
)
if
(
curr_join
->
tmp_having
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment