Bug #7596 group by function returning diverse column values for a row in a group

Submitted: 30 Dec 2004 21:51 Modified: 31 Dec 2004 1:47
Reporter: Paulo Habl Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server: MyISAM storage engine Severity:S1 (Critical)
Version:4.1.8nt OS:Windows (Win2k)
Assigned to: CPU Architecture:Any

[30 Dec 2004 21:51] Paulo Habl
Description:
I am having the following case which is returning discrepancies when using GROUP BY function.

A - These are all the rows for the SUBJECT ='Para Regina'

mysql> select received, id, senderid, subject
    -> from discussao
    -> where subject='Para Regina';
+---------------------+------+----------+-------------+
| received            | id   | senderid | subject     |
+---------------------+------+----------+-------------+
| 2003-09-28 17:56:43 | 4928 |     1218 | Para Regina |
| 2003-09-30 18:54:51 | 4965 |     1276 | Para Regina |
| 2003-10-01 04:22:06 | 4971 |     6509 | Para Regina |
| 2003-10-01 17:59:59 | 4983 |     1276 | Para Regina |
+---------------------+------+----------+-------------+
4 rows in set (0.00 sec)

>> All values returned are correct

B - Here is the first event of the SUBJECT in a period (min (received))

mysql> select min(received) received, id, senderid, subject
    -> from discussao
    -> where subject='Para Regina'
    -> group by subject;

+---------------------+------+----------+-------------+
| received            | id   | senderid | subject     |
+---------------------+------+----------+-------------+
| 2003-09-28 17:56:43 | 4928 |     1218 | Para Regina |
+---------------------+------+----------+-------------+
1 row in set (0.00 sec)

>>> The result is right

C - this is the row returned for the last event for the SUBJECT ('Para Regina')

mysql> select max(received) received, id, senderid, subject
    -> from discussao
    -> where subject='Para Regina'
    -> group by subject;
+---------------------+------+----------+-------------+
| received            | id   | senderid | subject     |
+---------------------+------+----------+-------------+
| 2003-10-01 17:59:59 | 4928 |     1218 | Para Regina |
+---------------------+------+----------+-------------+
1 row in set 

>> Here, the result is wrong!

Accordingly to the table above, it should return the row:

| 2003-10-01 17:59:59 | 4983 | 1276     | Para Regina |

the RECEIVED and SUBJECT are correct, but not ID and SENDERID

Could you check this for me?

Kind Regards

Paulo Habl

How to repeat:
Create a MyIsam table with the above data and execute similar queries.
[31 Dec 2004 1:47] Hartmut Holzgraefe
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.mysql.com/documentation/ and the instructions on
how to report a bug at http://bugs.mysql.com/how-to-report.php

Additional info:

See http://dev.mysql.com/doc/mysql/en/GROUP-BY-hidden-fields.html

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.039 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.