Filter duplicate Query Results

  • Thread starter hotrod1952 via AccessMonster.com
  • Start date
H

hotrod1952 via AccessMonster.com

SQL is:
SELECT WO.WOID, WOLabor.WOLaborDate, WO.DateRequired, EMPLOYEE.Name
FROM (WO INNER JOIN WOLabor ON WO.WONo = WOLabor.WONo) INNER JOIN EMPLOYEE ON
WO.AssignedToEmployee = EMPLOYEE.ID
GROUP BY WO.WOID, WOLabor.WOLaborDate, WO.DateRequired, EMPLOYEE.Name, WO.
DateCreated
HAVING (((WO.WOID) Like "PM*") AND ((WO.DateCreated)>=[START DATE dd/mm/yy]
And (WO.DateCreated)<DateAdd("d",1,[END DATE dd/mm/yy])) AND (([WOLabor]!
[WOLaborDate])>[WO]![DateRequired]))
ORDER BY WO.WOID, WO.DateCreated;

I have duplicate WOLaborDate entries in my table so my query returns the
duplicates. I want only the last enrty for each WO.WOID.
 
G

Guest

At first I thought that this was going to be easy; however, if your
WOLaborDate is duplicated, how do you tell which one is the last?
WO.DateCreated? If so try this:

SELECT WO.WOID,
WOLabor.WOLaborDate,
WO.DateRequired,
EMPLOYEE.Name,
Max(WO.DateCreated)
FROM (WO INNER JOIN WOLabor ON WO.WONo = WOLabor.WONo) INNER JOIN EMPLOYEE
ONWO.AssignedToEmployee = EMPLOYEE.ID
GROUP BY WO.WOID,
WOLabor.WOLaborDate,
WO.DateRequired,
EMPLOYEE.Name
HAVING (((WO.WOID) Like "PM*")
and ((WO.DateCreated)>=[START DATE dd/mm/yy]
and (WO.DateCreated)<DateAdd("d", 1, [END DATE dd/mm/yy]))
and (([WOLabor]![WOLaborDate])>[WO]![DateRequired]))
ORDER BY WO.WOID

You may need to mess with the Order By clause.
 
H

hotrod1952 via AccessMonster.com

There is a field in the WOLabor table called WOLaborNo which is an autonumber
field for each entry. If I can only figure a way to pick the largest of the
all for each duplicate in that field. HMM...

Jerry said:
At first I thought that this was going to be easy; however, if your
WOLaborDate is duplicated, how do you tell which one is the last?
WO.DateCreated? If so try this:

SELECT WO.WOID,
WOLabor.WOLaborDate,
WO.DateRequired,
EMPLOYEE.Name,
Max(WO.DateCreated)
FROM (WO INNER JOIN WOLabor ON WO.WONo = WOLabor.WONo) INNER JOIN EMPLOYEE
ONWO.AssignedToEmployee = EMPLOYEE.ID
GROUP BY WO.WOID,
WOLabor.WOLaborDate,
WO.DateRequired,
EMPLOYEE.Name
HAVING (((WO.WOID) Like "PM*")
and ((WO.DateCreated)>=[START DATE dd/mm/yy]
and (WO.DateCreated)<DateAdd("d", 1, [END DATE dd/mm/yy]))
and (([WOLabor]![WOLaborDate])>[WO]![DateRequired]))
ORDER BY WO.WOID

You may need to mess with the Order By clause.
SQL is:
SELECT WO.WOID, WOLabor.WOLaborDate, WO.DateRequired, EMPLOYEE.Name
[quoted text clipped - 9 lines]
I have duplicate WOLaborDate entries in my table so my query returns the
duplicates. I want only the last enrty for each WO.WOID.
 
G

Guest

That could work; however, autonumbers don't always increment upward. The only
thing an autonumber is garenteed to be is unique if using them as a primary
key.
--
Jerry Whittle
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.


hotrod1952 via AccessMonster.com said:
There is a field in the WOLabor table called WOLaborNo which is an autonumber
field for each entry. If I can only figure a way to pick the largest of the
all for each duplicate in that field. HMM...

Jerry said:
At first I thought that this was going to be easy; however, if your
WOLaborDate is duplicated, how do you tell which one is the last?
WO.DateCreated? If so try this:

SELECT WO.WOID,
WOLabor.WOLaborDate,
WO.DateRequired,
EMPLOYEE.Name,
Max(WO.DateCreated)
FROM (WO INNER JOIN WOLabor ON WO.WONo = WOLabor.WONo) INNER JOIN EMPLOYEE
ONWO.AssignedToEmployee = EMPLOYEE.ID
GROUP BY WO.WOID,
WOLabor.WOLaborDate,
WO.DateRequired,
EMPLOYEE.Name
HAVING (((WO.WOID) Like "PM*")
and ((WO.DateCreated)>=[START DATE dd/mm/yy]
and (WO.DateCreated)<DateAdd("d", 1, [END DATE dd/mm/yy]))
and (([WOLabor]![WOLaborDate])>[WO]![DateRequired]))
ORDER BY WO.WOID

You may need to mess with the Order By clause.
SQL is:
SELECT WO.WOID, WOLabor.WOLaborDate, WO.DateRequired, EMPLOYEE.Name
[quoted text clipped - 9 lines]
I have duplicate WOLaborDate entries in my table so my query returns the
duplicates. I want only the last enrty for each WO.WOID.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top