Bug #11439 Using SUM over empty rowset with group by + left join - returns NO RECORDS!!!
| Submitted: | 19 Jun 2005 20:11 | Modified: | 20 Jun 2005 9:36 |
|---|---|---|---|
| Reporter: | Marek Srom | Email Updates: | |
| Status: | Can't repeat | Impact on me: | |
| Category: | MySQL Server | Severity: | S2 (Serious) |
| Version: | 5.0.7 | OS: | Windows (Windows XP) |
| Assigned to: | CPU Architecture: | Any |
[19 Jun 2005 20:11]
Marek Srom
[19 Jun 2005 20:41]
Marek Srom
Changing severity to serious.
[19 Jun 2005 20:43]
Marek Srom
I guess this is optimiser bug, because works the same way when using for example sum(1) in the query
[20 Jun 2005 6:42]
Hartmut Holzgraefe
Please add *working* examples to this report (including CREATE TABLE statements, sample data if possible) The two queries in your report are obviously not working as they use inconsistant table names (t_customer vs. t_customers) and mix aggregate functions and regular columns without GROUP BY ...
[20 Jun 2005 7:27]
Marek Srom
Sorry, here is working SQL statement: create table t_customer(id int,number varchar(10)) GO create table t_point(id int,customer int, amount int) GO insert into t_customer values(1,'C001') GO --SELECT that works bad select number, COUNT(t_point.id), sum(t_point.amount) from t_customer left join t_point on t_customer.id=t_point.customer group by t_customer.number GO --SELECT that works ok select number, COUNT(t_point.id) from t_customer left join t_point on t_customer.id=t_point.customer group by t_customer.number GO
[20 Jun 2005 9:36]
Vasily Kishkin
I've got the follow result: mysql> select number, COUNT(t_point.id), sum(t_point.amount) from t_customer left join t_point on t_customer.id=t_point.customer group by t_customer.number; +--------+-------------------+---------------------+ | number | COUNT(t_point.id) | sum(t_point.amount) | +--------+-------------------+---------------------+ | C001 | 0 | NULL | +--------+-------------------+---------------------+ 1 row in set (0.05 sec)
[20 Jun 2005 12:04]
Marek Srom
tested more: - mywac command line - works OK - ODBC (Borland Database Explorer) - returns recordset with 1 row (OK) but SUM column is missing (even when I add one more column behind it, or move it to the frist place) - ADO - returns EOF, sum field is in fields collection ODBC driver problem?
Portions of this website are copyright © 2001, 2002 The PHP Group
Page generated in 0.054 sec. using MySQL 8.4.7-u6-cloud
Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the
respective copyright holders.
It is not reviewed in advance
by Oracle and does not necessarily represent the opinion of
Oracle or any other party.