FW: [PHP-DB] Query select value on MAX Date
| From: | Nur_Adman at fmi dot com | Date: | Fri, 24 Feb 2006 23:07:36 +0000 |
| Subject: | FW: [PHP-DB] Query select value on MAX Date | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-41320@lists.php.net to get a copy of this message | ||
Dear All,
Sorry, I wrote the wrong result.
The result I wanna get is :
Id | Category | Date |
Value
1 | A | 2005-02-21 |
2000
3 | B | 2006-01-20 |
4000
But I got :
Id | Category | Date |
Value
1 | A | 2005-02-21 |
3000
3 | B | 2006-01-20 |
5000
The MAX(Date) id correct, but the incorrect value...
Thanks & Regards,
Anita
________________________________
From: Adman, Nur anita
Sent: Saturday, February 25, 2006 6:05 AM
To: 'php-db@lists.php.net'
Subject: RE: [PHP-DB] Query select value on MAX Date
Dear All,
I have table like this :
Id | Category | Date |
Value
1 | A | 2005-02-21 |
2000
2 | A | 2004-01-21 |
3000
3 | B | 2006-01-20 |
4000
4 | B | 2005-12-11 |
5000
I want to get the value for each Category where the date is MAX.
So I make the query like this :
"SELECT MAX(Date), Value FROM table GROUP BY Category"
But I get is :
Id | Category | Date |
Value
1 | A | 2005-02-21 |
2000
3 | B | 2006-01-20 |
4000
Could you help me please?
Thanks & Regards,
Anita