Posted by Tyrone Slothrop on 04/03/07 05:23
I have a table which stores a member score on a monthly basis. I need
to run a query which finds those members who have seen the greatest
improvement and those who have shown the greatest loss from one month
to the next.
The fields:
member_id (integer)
score (double 3,1)
date (date)
I can find the greatest differences for the past two months with a
query like:
SELECT member_id, max(score) - min(score) as diff FROM monthly _report
WHERE MONTH(CURDATE())=MONTH(Date)-1 OR
MONTH[CURRDATE())=MONTH(Date)-2 GROOUP BY member_id;
However, as I said before, I need to find those which show the
greatest improvement and those who have shown the greatest loss
between the two months.
Is there are way of accomplishing this with a single query?
TIA!
[Back to original message]
|