470,573 Members | 1,735 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,573 developers. It's quick & easy.

Help me with group by query in MYSQL 3.x

Hello experts,

I have a little group by problem, hope you can help me.
I have a lot off records which I want to group by "HOUR(timefield)"

example:

01-02-2005 13:28:00 25.0
01-02-2005 13:11:01 24.0
01-02-2004 13:10:03 23.5
01-01-2005 12:08:00 25.0
01-01-2005 12:01:01 24.0
01-01-2004 12:00:03 23.5

I want to group them by HOUR(timefield) if I do this I get the first
record of all the groups
result below:
01-02-2004 13:10:03 23.5
01-01-2004 12:00:03 23.5

However I want the last records of each group
result I want:
01-02-2005 13:28:00 25.0
01-01-2005 12:08:00 25.0

Who can help me on this
thanks guys
Regards
Pieter

Dec 11 '05 #1
3 1692
"Wire" <wi*****@zonnet.nl> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
I have a little group by problem, hope you can help me.
I have a lot off records which I want to group by "HOUR(timefield)"
However I want the last records of each group


See the thread "problem with nested select" a couple of days ago on this
newsgroup. Your problem is equivalent to the one in that thread.

Regards,
Bill K.
Dec 12 '05 #2
Hi Bill

I saw the thread
but I think that is not my problem
Please help

Dec 12 '05 #3
Wire wrote:
I have a little group by problem, hope you can help me.
I have a lot off records which I want to group by "HOUR(timefield)"


You need to join the table with itself to gain the results you wish.
Examples can be found from the comments in this page (subquery examples
won't work with 3.x, so don't bother trying those).

http://dev.mysql.com/doc/refman/5.0/...group-row.html
Dec 12 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Petre Agenbag | last post: by
7 posts views Thread by Jim | last post: by
6 posts views Thread by Ljoha | last post: by
4 posts views Thread by Dejan | last post: by
9 posts views Thread by axlq | last post: by
5 posts views Thread by inexion | last post: by
1 post views Thread by chienee | last post: by
1 post views Thread by livre | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.