Hi

Story goes - I have an online store... there is a sales table which records every product sold.

Each product is within a style. So a Style might be 'Red Jacket'.

I want to pull out (from the sales table), in order of how many sales have been made, the distinct Style IDs of all of my products. Is this possible in one query?

Thanks
lworks

Sure, assuming that each sale record had a "Qty" for quantity sold, you'd just have something like

SELECT StyleID, SUM(Qty) FROM Sales GROUP BY StyleID ORDER BY SUM(Qty) DESC
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.