[AccessD] Last Date Query

William Benson vbacreations at gmail.com
Thu Dec 22 11:02:06 CST 2011


Ill go out on a limb and suppose that you really meant the Max date since
the sample data was in ascending date order.

Select tbl1.Pat, tbl1.Result from Tbl1 where tbl1.date =(Select
Max(t2.Date) From Tbl1 as t2 Where t2.Pat = Tbl1.Pat)

That is "air code" I have not tested it.
On Dec 22, 2011 6:39 AM, <pedro at plex.nl> wrote:

>
> Hello Group, i want the last dat from tbl1
>
> Pat     Date       Result
> A1     01-01-11    15
> A1     10-10-11     7
> A1     11-11-11     6
>
> When i use the query:
>
> SELECT tbl1.Pat, Last(tbl1.Date) AS LastDate, tbl1.Result
> FROM tbl1
> GROUP BY tbl1.Pat, tbl1.Result;
>
> Then is stil have these three records because of the Result
>
> What i need is only record that is really the last date, regardless what
> value there is for result
>
> Pat     LastDate         Result
> A1     11-11-11           6
>
>
> I have done this before, but i can't remember how.
> Is has to been done with a subquery.
>
> Who can help me?
>
> Thanks
>
> Pedro
> --
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
>



More information about the AccessD mailing list