Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

extract records with the smallest value per group

Posted on 2014-04-17
2
277 Views
Last Modified: 2014-04-18
I have a table containing the following

  Acct #       Collection Date/Time       Result Date/Time       Clinical Event
000005        1/1/2014 00:10:00           1/1/2014 00:42:00     Troponin-T
000005        1/1/2014 00:15:00           1/1/2014 00:20:00     Troponin-I
000005        1/1/2014 01:30:00           1/1/2014 02:10:00     Troponin-T
001002        1/3/2014 23:59:00           1/4/2014 00:45:00     Troponin-T
001002        1/4/2014 05:20:00           1/4/2014 05:25:00     Troponin-I

I need a query that would pull the entire record with the earliest result time for each account.  

For Acct # 0005, I need the record with result date/time of 1/1/2014 00:20:00 (2nd rec)
For Acct # 1002, I need the record with result date/time of 1/4/2014 00:45:00 (4th rec)
0
Comment
Question by:ddschreck01
2 Comments
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 500 total points
ID: 40007874
test this query


 Select A.*
 From Tablex as A
 Inner join
 (Select min(B.[Result Date/Time]) as MinResult, B.[Acct #]
  from TableX as B
  Group by B.[Acct #]
  ) As C
  On A.[Acct #]= C.[Acct #] And A.[Result Date/Time]=C.[MinResult]
0
 

Author Closing Comment

by:ddschreck01
ID: 40008766
Thank you very much - that worked perfectly.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question