Problem using Min(field)

Posted by Todd on Stack Overflow See other posts from Stack Overflow or by Todd
Published on 2010-05-13T15:36:18Z Indexed on 2010/05/13 15:44 UTC
Read the original article Hit count: 134

Filed under:

have these two queries:

SELECT classroomid AS crid, startdate AS msd
FROM unitTemplates where classroomid = 6
GROUP BY classroomid

and:

SELECT classroomid AS crid, Min(startdate) AS msd
FROM unitTemplates where classroomid = 6
GROUP BY classroomid

The second query uses the minimum function. There is only one record in my table with a classroomid of 6. The first query returns msd = 20100505, the second query returns msd = 0 (instead of the expected 20100505). If I change the "Min" to "Max" it returns the highest (and only) startdate (20100505).

Why doesn't MySQL like the Min function I'm using?

© Stack Overflow or respective owner

Related posts about mysql