If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > General > New Members & Introductions > First & Last records in a group

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-11-12, 00:26
TAGOSO TAGOSO is offline
Registered User
 
Join Date: Feb 2012
Posts: 3
Question First & Last records in a group

Hi there, I have a group of records like this;

NAME| RUN START| RUN END| LK1| LK2| DESC
Graeme Brown| 2012-02-23 07:20:00.0000000| 2012-02-23 07:50:00.0000000| 2213| 2244| AK1/4/PI2
Graeme Brown| 2012-02-23 08:00:00.0000000| 2012-02-23 09:25:00.0000000| 2244| 2052| AK1/4/PI2
Graeme Brown| 2012-02-23 09:30:00.0000000| 2012-02-23 11:05:00.0000000| 2052| 917| AK1/4/PI2
Graeme Brown| 2012-02-23 12:15:00.0000000| 2012-02-23 13:55:00.0000000| 917| 2052| AK1/4/PI2
Graeme Brown| 2012-02-23 14:05:00.0000000| 2012-02-23 15:40:00.0000000| 2052| 1111| AK1/4/PI2

I want to get;

NAME| RUN START| RUN END| LK1| LK2| DESC
Graeme Brown| 2012-02-23 07:20:00.0000000| 2012-02-23 15:40:00.0000000| 2213| 1111| AK1/4/PI2

So what it needs to do is combine the ;

earliest RUN START and corresponding LK1 with
latest RUN END and corresponding LK2

Can anyone please help? I've tried creating temp tables with the mins and maxs - but then I can't combine them with the LK1 and Lk2 fields...
I'm a bit lost...

Thank you in advance!
Reply With Quote
  #2 (permalink)  
Old 02-11-12, 02:53
tonkuma tonkuma is offline
Registered User
 
Join Date: Feb 2008
Location: Japan
Posts: 2,205

Last edited by tonkuma; 02-11-12 at 05:04. Reason: Add ANSI SQL
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On