Something like this should work - (but is untested), and does require the extra 
subquery, so there may be a more efficient way?

However, off the top of my head: 

select a,b,c 
from table
where 
order by c desc
limit (select count(*)/10 from table where );


where c is the no of sales column



Brent Wood
DBA/GIS consultant
NIWA, Wellington
New Zealand
>>> Tim Uckun  10/18/10 3:40 PM >>>
Is there a way to select the top 10% of the values from a column?

For example the top 10% best selling items where number of sales is a column.

Thanks.

-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

NIWA is the trading name of the National Institute of Water & Atmospheric 
Research Ltd.

Reply via email to