#1
  1. No Profile Picture
    Registered User
    ASP Explorer (0 - 99 posts)

    Join Date
    Dec 2006
    Posts
    12
    Rep Power
    0

    Exclamation 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!!!!!
  2. #2
  3. **Wanted Wizard**
    ASP Mastermind (5000+ posts)

    Join Date
    Apr 2006
    Location
    Who knows...
    Posts
    5,410
    Rep Power
    1341
    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
    I would rather know than not know at all...


  4. #3
  5. Senior Sarcasm Wizardess
    ASP Mastermind (5000+ posts)

    Join Date
    Feb 2005
    Location
    Dreamland
    Posts
    13,608
    Rep Power
    2466
    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.
    Quote of the Month:
    Planning: Much work remains to be done before we can announce our total failure to make any progress.

    Questions to Ponder:
    If convenience stores are open 24 hours a day, 365 days a year, why are there locks on the doors?

    iif([sarcasm]=true,iif([you have to ask]=true,"didn't work","ha ha ha"),"not sarcasm")
    copyright© 2008 sbenj69

Similar Threads

  1. Replies: 3
    Last Post: February 15th, 2006, 11:45 AM
  2. Query return the unmatched record incorrectly
    By desiboy681 in forum SQL Development
    Replies: 2
    Last Post: January 17th, 2006, 10:30 AM
  3. Replies: 9
    Last Post: March 10th, 2005, 12:28 AM
  4. Need help/suggestion on writing this query?, Query help
    By rudyten in forum SQL Development
    Replies: 5
    Last Post: September 27th, 2004, 09:15 AM
  5. Lose record edit via form; input continues as new record
    By Karenk in forum Microsoft Access Help
    Replies: 1
    Last Post: September 23rd, 2004, 03:19 PM

IMN logo majestic logo threadwatch logo seochat tools logo