Marcel1993 Posted November 23, 2011 Share Posted November 23, 2011 Hey guys, I've got a table with the following contents: CID VALUE TIME 1 A 500 1 B 700 1 C 400 2 D 100 2 E 300 3 F 100 Now I want to output this table without having entries with the same CID. If a entry got a unique CID it is supposed to get displayed. If several entries got the same CID, only the entry with the highest time is supposed to get displayed: Example: 1 B 700 2 E 300 3 F 100 Is there a way to solve it in SQL? Thanks :-) Quote Link to comment https://forums.phpfreaks.com/topic/251686-get-latest-entries-of-a-defined-row/ Share on other sites More sharing options...
PFMaBiSmAd Posted November 23, 2011 Share Posted November 23, 2011 http://dev.mysql.com/doc/refman/5.5/en/example-maximum-column-group-row.html Quote Link to comment https://forums.phpfreaks.com/topic/251686-get-latest-entries-of-a-defined-row/#findComment-1290752 Share on other sites More sharing options...
fenway Posted November 23, 2011 Share Posted November 23, 2011 Basically, you self-join the table, and find the rows that don't have any greater matching value for CID, Quote Link to comment https://forums.phpfreaks.com/topic/251686-get-latest-entries-of-a-defined-row/#findComment-1290814 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.