Monday, March 26, 2012

Max

Hi ,
I have a list of data as show below ,
Data1 Update Date
-- --
1 01-01-2004
2 01-01-2004
3 01-01-2004
1 01-01-2005
2 01-01-2005
3 01-01-2005
How can I build a query to select the "latest" update date data from this
list ?
Travis Tan
On Mon, 7 Nov 2005 08:31:14 -0800, Travis wrote:

>Hi ,
> I have a list of data as show below ,
> Data1 Update Date
> -- --
> 1 01-01-2004
> 2 01-01-2004
> 3 01-01-2004
> 1 01-01-2005
> 2 01-01-2005
> 3 01-01-2005
> How can I build a query to select the "latest" update date data from this
>list ?
Hi Travis,
Your question is not reallly clear. Providing expected output would have
been helpful. (And posting CREATE TABLE and INSERT statements even more;
check www.aspfaq.com/5006).
Anywway, here are two possible answers for two possible interpretations
of your question:
SELECT MAX("Update Date")
FROM YourTable
SELECT Data1, MAX("Update Date")
FROM YourTable
GROUP BY Data1
Best, Hugo
(Remove _NO_ and _SPAM_ to get my e-mail address)
sql

No comments:

Post a Comment