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
9a7b0ef8
Commit
9a7b0ef8
authored
Mar 25, 2003
by
monty@narttu.mysql.fi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed bug with GROUP BY and alias
parent
58472943
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
0 deletions
+32
-0
mysql-test/r/group_by.result
mysql-test/r/group_by.result
+19
-0
mysql-test/t/group_by.test
mysql-test/t/group_by.test
+12
-0
sql/item.cc
sql/item.cc
+1
-0
No files found.
mysql-test/r/group_by.result
View file @
9a7b0ef8
...
@@ -569,3 +569,22 @@ a MAX(b) MAKE_SET(MAX(b), 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h')
...
@@ -569,3 +569,22 @@ a MAX(b) MAKE_SET(MAX(b), 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h')
1 4 c
1 4 c
10 43 a,b,d,f
10 43 a,b,d,f
drop table t1;
drop table t1;
create table t1 (id int not null, qty int not null);
insert into t1 values (1,2),(1,3),(2,4),(2,5);
select id, sum(qty) as sqty, count(qty) as cqty from t1 group by id having sum(qty)>2 and cqty>1;
id sqty cqty
1 5 2
2 9 2
select id, sum(qty) as sqty from t1 group by id having sqty>2 and count(qty)>1;
id sqty
1 5
2 9
select id, sum(qty) as sqty, count(qty) as cqty from t1 group by id having sqty>2 and cqty>1;
id sqty cqty
1 5 2
2 9 2
select id, sum(qty) as sqty, count(qty) as cqty from t1 group by id having sum(qty)>2 and count(qty)>1;
id sqty cqty
1 5 2
2 9 2
drop table t1;
mysql-test/t/group_by.test
View file @
9a7b0ef8
...
@@ -417,3 +417,15 @@ select a, MAX(b), CONCAT_WS(MAX(b), '43', '4', '5') from t1 group by a;
...
@@ -417,3 +417,15 @@ select a, MAX(b), CONCAT_WS(MAX(b), '43', '4', '5') from t1 group by a;
select
a
,
MAX
(
b
),
ELT
(
MAX
(
b
),
'a'
,
'b'
,
'c'
,
'd'
,
'e'
,
'f'
)
from
t1
group
by
a
;
select
a
,
MAX
(
b
),
ELT
(
MAX
(
b
),
'a'
,
'b'
,
'c'
,
'd'
,
'e'
,
'f'
)
from
t1
group
by
a
;
select
a
,
MAX
(
b
),
MAKE_SET
(
MAX
(
b
),
'a'
,
'b'
,
'c'
,
'd'
,
'e'
,
'f'
,
'g'
,
'h'
)
from
t1
group
by
a
;
select
a
,
MAX
(
b
),
MAKE_SET
(
MAX
(
b
),
'a'
,
'b'
,
'c'
,
'd'
,
'e'
,
'f'
,
'g'
,
'h'
)
from
t1
group
by
a
;
drop
table
t1
;
drop
table
t1
;
#
# Problem with group by and alias
#
create
table
t1
(
id
int
not
null
,
qty
int
not
null
);
insert
into
t1
values
(
1
,
2
),(
1
,
3
),(
2
,
4
),(
2
,
5
);
select
id
,
sum
(
qty
)
as
sqty
,
count
(
qty
)
as
cqty
from
t1
group
by
id
having
sum
(
qty
)
>
2
and
cqty
>
1
;
select
id
,
sum
(
qty
)
as
sqty
from
t1
group
by
id
having
sqty
>
2
and
count
(
qty
)
>
1
;
select
id
,
sum
(
qty
)
as
sqty
,
count
(
qty
)
as
cqty
from
t1
group
by
id
having
sqty
>
2
and
cqty
>
1
;
select
id
,
sum
(
qty
)
as
sqty
,
count
(
qty
)
as
cqty
from
t1
group
by
id
having
sum
(
qty
)
>
2
and
count
(
qty
)
>
1
;
drop
table
t1
;
sql/item.cc
View file @
9a7b0ef8
...
@@ -665,6 +665,7 @@ bool Item_ref::fix_fields(THD *thd,TABLE_LIST *tables)
...
@@ -665,6 +665,7 @@ bool Item_ref::fix_fields(THD *thd,TABLE_LIST *tables)
maybe_null
=
(
*
ref
)
->
maybe_null
;
maybe_null
=
(
*
ref
)
->
maybe_null
;
decimals
=
(
*
ref
)
->
decimals
;
decimals
=
(
*
ref
)
->
decimals
;
binary
=
(
*
ref
)
->
binary
;
binary
=
(
*
ref
)
->
binary
;
with_sum_func
=
(
*
ref
)
->
with_sum_func
;
}
}
return
0
;
return
0
;
}
}
...
...
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