FW: Query select value on MAX Date

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxx'
Subject: RE:  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

 

 

 

 

 

 

 

 


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux