I have a table full of items and prices for said items. I would like to grab the SUM of the 3 highest priced items.
I thought perhaps SELECT SUM(items.price) FROM items ORDER BY items.price LIMIT 3
but that does not seem to do the trick. Is this possible? Thanks!
Just use a sub-select:
I haven't tested this and I just wrote it on my memory. You could try something like:
Edit: I was slow
LIMIT
affects the number of rows returned by the query and SUM only returns one. Based on this thread you might want to try:Use a subquery or something like that. Just an idea, as I have not tested the actual query.