Microsoft
Software
Hardware
Network
Question : Select DISTINCT Question
I have two tables in a database; the first table is companies with a unique autonumber named ID as the primary key. The second table is named case_notes and has a filed named employer_id that is related to the ID fiield in the first table the relatiionship is a one-to-many - whereas the case_notes table can contain many employer_id's from the first table. The image shows the relationship and relevant fields. Users of the database can add ‘notes’ in the case_notes table; again each company can have many case_notes.
I need to be able to create a query that will return a list of distinct companies that includes the most recent case note based on the date field in the case_notes table. This of course is an Access database. Thanks in advance
Attachments:
case-notes.gif
(7 KB)
(File Type Details)
Relationship Map
Answer : Select DISTINCT Question
SELECT company, a.MaxDate
FROM
(
SELECT employer_id, MAX([Date]) as MaxDate
FROM employers e
INNER JOIN case_notes c
ON e.ID = c.employer_id
GROUP BY employer_id) as a
WHERE id=a.employer_id
Random Solutions
VS 2008 C# Make Non-Modal behave as Modal
How can I grep 2 digital year information in Redhat linux
bkf / bks files
Terminal Services connections and Exchange 2010
Dynamically Embed Canonical link in Head using ColdFusion
How do I have an SQL incremental column for each user?
file system structure on the disk is corrupt on \Device\HarddiskVolumeShad
owCopy31
How to Query Same Table twice using 1 SQL Query ?
How do I prevent my app from being indexed by search engines
How to set VBA UserForm Textbox format to ###,###,###.00?