-
February 14th, 2011, 02:23 AM
#1
MYSQL Query -AVG Last two days
I am trying to get Average of last two records and group them by name.
Tables: S_ORDER
OId ODate Value Name
1 05/01/2011 25 Mike
2 05/01/2011 56 Peter
3 05/01/2011 09 Robert
4 06/01/2011 21 Mike
5 06/01/2011 52 Peter
6 06/01/2011 04 Robert
7 10/01/2011 28 Mike
8 10/01/2011 57 Peter
9 10/01/2011 03 Robert
MySQL:
SELECT Name, avg(Value) as avg_score
FROM (
SELECT Name, Value FROM S_ORDER BY desc ODate 2
)
GROUP BY Name;
Thank you.!
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|