Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
SELECT order.name, SUM(vz.volume),SUM(vz.sales),SUM(vz.post_volume),SUM(vz.post_sales), SUM(vz.sales)/SUM(vz.volume) AS 'Ratio'FROM vz_delivery vz, vz_order ORDERWHERE vz.order_id = order.idAND DATE BETWEEN '2010-01-01' AND ' 2011-04-30'GROUP BY order.name
How can I SHOW the results of the top 20% of results BY Ratio? So the top 20 highest ratios?
robvolk
Most Valuable Yak
15732 Posts
Posted - 2011-05-10 : 14:31:30
SELECT TOP 20 PERCENT order.name, SUM(vz.volume),SUM(vz.sales),SUM(vz.post_volume),SUM(vz.post_sales), SUM(vz.sales)/SUM(vz.volume) AS 'Ratio'FROM vz_delivery vz, vz_order ORDERWHERE vz.order_id = order.idAND DATE BETWEEN '2010-01-01' AND ' 2011-04-30'GROUP BY order.nameORDER BY Ratio DESC