You can do it either by using separate queries as Karl suggests or in a
single query with subqueries, e.g. to average customers' orders by amount,
excluding the highest and lowest per customer:
SELECT Customer, AVG(Amount)
FROM Customers INNER JOIN Orders AS O1
ON Customer.CustomerID = O1.OrderID
WHERE Amount <
(SELECT MAX(Amount)
FROM Orders AS O2
WHERE O2.CustomerID = O1.CustomerID)
AND Amount >
(SELECT MIN(Amount)
FROM Orders AS O3
WHERE O3.CustomerID = O1.CustomerID)
GROUP BY Customer;
However, if a customer had two orders of the same amount which happened to
be either their MAX or MIN amounts, then the average would exclude both of
those, which might or might not be what you want.
Ken Sheridan
Stafford, England