Tell me more ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.
SELECT 
    `products`.* 
FROM `products` 
    INNER JOIN collection_items ON products.collection_item_id = collection_items.id 
        WHERE `products`.`product_type_id` = 1 
AND (products.status = 'live') 
AND (products.belongs_to_sv = true) 
ORDER BY products.weight DESC

I am trying to get the record set ordered by products.weight but with only unique values for products.collection_item_id.

When I try to group, the ORDER BY isn't obeyed.

share|improve this question
Hi Rory. Do you have some example data and a required output example? Currently it's a little ambiguous about what you'd like to return from the group by. For instance do you want to sort by the maximum weight in a collection_item_id, or the minimum, or the average, or the sum? – Stuart Moore Nov 2 '12 at 7:33

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.