Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

SQL Query

Posted on 2013-11-14
3
Medium Priority
?
416 Views
Last Modified: 2013-12-12
Access 2010

Ok I am using Access to get data from 375,000 records.  I know I have 23,000 unique people associated with the records.  columns A,B,C,D are all static information about the person.  I also have a date last seen which I want to use the max date.

How do I use the max of the date to find the latest instance of the complete record.  Every time I try to use the max date and include any column F,G,H, I  it gives me all of the records.

I have searched and I can't quite tie the answers to my data.

I have a unique id column (A),  person ID column (B), and a date last seen column (E), I can't figure out how to get the max date (E) and still include the (A) to let me join to the rest of my data.
0
Comment
Question by:Sean Meyer
[X]
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
3 Comments
 
LVL 61

Expert Comment

by:mbizup
ID: 39649223
Start with a grouping query:

Select personID, max(datefield) as lastSeen
From yourTable
Group by personID

Save the query.

Create another query joining your people table to that query, linking it on personID and LastSeen.
0
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 1400 total points
ID: 39649296
try this single query


select a.*
from TableName as a
inner join
(select b.[person ID],max(b.[date last seen]) as maxdate
      from tableName as b
      group by b.[person ID]) as c
on a.[person ID]=c.[person ID] and a.[date last seen]=c.[maxDate]


.change tableName with the actual name of table and fields accordingly
0
 
LVL 32

Assisted Solution

by:awking00
awking00 earned 600 total points
ID: 39651268
select a.*
from yourtable a,
(select personid, max(date) as maxdt
 from yourtable
 group by personid) as b
where a.personid = b.personid
  and a.date = b.maxdt;
0

Featured Post

Enroll in September's Course of the Month

This month’s featured course covers 16 hours of training in installation, management, and deployment of VMware vSphere virtualization environments. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

670 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