Muliple SQL statements / Return percentage of rows

I’m stumped…

I need to return a number of rows with the top & bottom x percentage of
rows removed in mysql 4.x e.g.

SELECT COUNT() value_count,
SUM(deals.value) / COUNT(
) average_value
FROM deals
ORDER BY deals.value

Now say that returns the sum of 100 deals, what I actually need to do is
return the count & sum of rows 10-90 (i.e. the top & bottom 10% rows
removed)

I found this which I can adapt but it requires two sql statements
http://www.gloomy.eu/mysql-desired-percentage-of-rows/

And this helpful article explains how to execute multiple statements in
rails but it doesn’t seem to work with variables.
http://public.ok2life.com/welcome/index/46.html

Anyone have any other ideas?

Thanks
Luke

And this helpful article explains how to execute multiple statements in
rails but it doesn’t seem to work with variables.
http://public.ok2life.com/welcome/index/46.html

Scratch that this does work with variables - if anyone has a decent way
of doing the original problem though I’d be glad to hear.

Cheers
Luke