Stuart McLachlan
stuart at lexacorp.com.pg
Tue Dec 11 15:32:18 CST 2012
You need the Max for EACH day, not the max for the PK. See my posting. -- Stuart On 11 Dec 2012 at 13:24, David McAfee wrote: > is there a PKID for the table? > > SELECT PKID, MAX(SomeDateFiekd) AS MaxDate FROM SomeTable > > > You'll have to join back to the same table if you want more data from the table: > > SELECT B.* > FROM > (SELECT PKID, MAX(SomeDateField) AS MaxDate FROM SomeTable) A > INNER JOIN SomeTable B ON A.PKID = B.PKID AND A.MaxDate = B.SomeDateField > > > On Tue, Dec 11, 2012 at 12:58 PM, Kaup, Chester > <Chester_Kaup at kindermorgan.com> wrote: > > I have a database with linked SQL server table. I need to extract some records from the table. Some days there is more than one record; ie two records with different times. I need to grab the last record on those days. So far I have not come up with a way. Your ideas appreciated. > > -- > > AccessD mailing list > > AccessD at databaseadvisors.com > > http://databaseadvisors.com/mailman/listinfo/accessd > > Website: http://www.databaseadvisors.com > > -- > AccessD mailing list > AccessD at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/accessd > Website: http://www.databaseadvisors.com >