I have a table that logs rows with some duplicate data.
The column fields are as follows:
id: primary key, auto inc.
member_id: int index
item_qt: int
id, member_id, item_qt, timestamp
553, 107, 10, time
552, 107, 25, time
551, 122, 6, time
550, 122, 9, time
549, 107, 19, time
I would like to do a few things:
How would you select the latest unique rows,
sum the item_qt,
join on a 'username' table. cols: id, name
and sort descending
Anyone have suggestions for a subselect query
without the high overhead of filesorting? Or possibly another reconfiguration of the data?
This is very similar: I just can't get the syntax correct.
http://stackoverflow.com/questions/1227619/retrieve-last-latest-distinct-highest-value