Home > Microsoft Access Help > Query to Pull First & Last Record?

Query to Pull First & Last Record?



I am having trouble. I have a log table and I am trying to pull two records at once. The records im trying to pull is the most recent record update as well as the original record.



Example:



I want to pull for Toysrus the first log intry for this company when I first put the record in. And I want to pull the most recent update that I did for this company. Is there a way to pull both records at the same time? The first and the last?



Any help would be appreciated. THANK YOU SO MUCH!!!!!

    
Guest


not sure if this will work or not, but worth a try:

here is an example


Code:


select top 1 dealer_name as name, (select top 1 city from Dealer_Profile order by City desc) as city 
from Dealer_Profile
order by name asc



Was this answer helpful ? Yes No   
Guest


if you have dates the indicate this info, you could possible use a union query. something like this:


Code:


select name, min(date) from tbl_TableName where name = 'something' group by name
union all
select name, max(date) from tbl_TableName where name = 'something' group by name




min(date) should return the first record, max(date) should return the most recent updated record.

Was this answer helpful ? Yes No   
Guest
 
 
Home - About Infoqu - Contact - Privacy Statement - Link to Infoqu - Bookmark Infoqu

Copyright 2007-2008 by Infoqu. All rights reserved