Try 

select thread, subject, max(time)
from jos_sb_messages
group by thread
order by 3

-----Original Message-----
From: The Nice Spider [mailto:[EMAIL PROTECTED]
Sent: Thursday, 10 August 2006 4:10 p.m.
To: mysql@lists.mysql.com
Subject: Group by base on latest time field, possible?


I want the group by result take the latest field, but
my query result look 
like get the random row.
Here I described:

Thread Subject                    Time
-----------------------------------------
5         Re:test 3333333333 1155203794
5         test 3333333333      1155203772
8         test 444                    1155203882
8         Re:test 444               1155203897

note: "time" field is INT(11) to store datetime in
integer value

QUERY
---------
select thread, subject, time
from jos_sb_messages
group by thread
order by time

RESULT
----------
5 Re:test 3333333333 1155203794
8 test 444                    1155203882

What do I need is:
------------------
5         Re:test 3333333333 1155203794
8         Re:test 444                1155203897

I am using 3.23.58 for Windows.
How to get the result as I expected? 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]
The information contained in this email is privileged and confidential and
intended for the addressee only. If you are not the intended recipient, you
are asked to respect that confidentiality and not disclose, copy or make use
of its contents. If received in error you are asked to destroy this email
and contact the sender immediately. Your assistance is appreciated.

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to