Try adding max(session_modified).
SELECT *,max(session_modified) AS LastMod FROM translines GROUP BY
session_id ORDER BY session_modified DESC
On Jun 29, 2005, at 8:00 AM, Lee Denny wrote:
Hello,
If got a simple sessions table basically holds a session id and
datetime
field for last modification also a session type, so I can have several
records with the same session id, with different types and different
modification time. I want to get the latest modified record for any
given
session, and I'm using
SELECT * FROM translines GROUP BY session_id ORDER BY session_modified
DESC
on this example data set :
session_id | type | date_modified
d36631973996623650e5e1caae5686ca 1 2005-06-29 11:40:00
d36631973996623650e5e1caae5686ca 2 2005-06-29 11:34:41
d36631973996623650e5e1caae5686ca 1 2005-06-29 10:50:41
d36631973996623650e5e1caae5686ca 3 2005-06-29 10:50:41
09ebae82723018355559c519cc3bb0ca 2 2005-06-28 20:38:18
Although this returns the individual sessions in the correct order, the
group by is returning the earliest record for that session_id so I
get:
d36631973996623650e5e1caae5686ca 3 2005-06-29 10:50:41
09ebae82723018355559c519cc3bb0ca 2 2005-06-28 20:38:18
Rather than
d36631973996623650e5e1caae5686ca 1 2005-06-29 11:40:00
09ebae82723018355559c519cc3bb0ca 2 2005-06-28 20:38:18
Which is what I want, I'm sure this is a misunderstanding on my part,
but
does any one have any ideas?
All the best,
Lee
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:
http://lists.mysql.com/[EMAIL PROTECTED]
--
Brent Baisley
Systems Architect
Landover Associates, Inc.
Search & Advisory Services for Advanced Technology Environments
p: 212.759.6400/800.759.0577
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]