No practical use for such a table, but then let's say I run the following Query:
SELECT *, SUM(*)
FROM `purchases`
GROUP BY `name`;
The follow will output:
1...Ben.....2....3/6/2010
2...Chris..6....3/8/2010
3...John...4....3/10/2010
Well, I was wanting for it to group in reverse order. I want it to show Chris after John, and show record 4 Chris 6 3/12/2010. I want the latest purchase date. I'm actually pulling a LOT of data from a table in reverse order by their ID. I need their last purchase date, and it shows their FIRST purchase date. Is the only way to do this is to make the FROM value the purchases table queried in reverse ORDER BY? Like this?
SELECT *,SUM(*)
FROM (SELECT * FROM purchases as `a` ORDER BY `a`.`id` DESC)
GROUP BY `name`;
I don't know if the above will actually work, but I'm trying to avoid using a query inside of a query. If needed though, it's not used very often, but is still a lot of overhead I'd rather not get myself into. If anyone has any suggestions, please let me know, they'd be greatly appreciated (:
Hey guys, I just realized it doesn't always grab the first or last record, seems to be random... not quite sure what to do. Should I find a different method?
You do not have permission to post replies to topics in this board. If you want to join in with discussions and create new topics please register. If you want to register your own free account with us, please click here.