select top 20% from each category
Posted on 2010-09-12
I took a shot at this statement, I get a runtime 3138 error, "syntax error in order by clause."
SELECT TOP 20 percent * into test FROM Products ORDER BY UnitPrice DESC , group by category
I assume this statement without the group by would get the first 20 highest priced products (if there were 100). My problem is similar in that I have multiple categories, and would like the highest priced 20 percent , for each category, putting a group by at the end was what preliminary logic told me to atleast try.