Criteria X-OR

shafara7

Registered User.
Local time
Today, 06:25
Joined
May 8, 2017
Messages
118
I have a table and I want to create a query with a criteria X-OR.

My table looks like this:
BillID CountryID TaskID Dates
10 1 3 01.01.2017
20 2 3 01.02.2017
30 2 4 01.03.2017
40 1 4 01.04.2017
10 2 6 01.05.2017
10 1 4 01.06.2017
20 3 1 01.07.2017

The BillID can be duplicated, but there can only be one BillID for each country.
I want to consider only the TaskID 3 and 4 in this query.
When I set my TaskID to 3 Or 4, the query showed both the records in green.
But I only want it to show either the record with TaskID 3 or 4 but not both, provided that the second record is the latest record. So it should only show BillID 10 Country 1 TaskID 4.
Plus, I already set the Dates to Max, so that it only pick the latest one.
When I set the criteria 3 X-Or 4, the same result is shown.
 
Base a query on the query you've, then use the Max function on the Dates.
 
SELECT tblMessauftrag.txtTeilesachnummer, tblMessauftrag.indFOLand, Max(tblMessauftrag.datLieferterminSoll) AS MaxvondatLieferterminSoll, tblMessauftrag.indMessaufgabe, Last(tblMessauftrag.indStatus) AS LetzterWertvonindStatus
FROM tblMessauftrag
GROUP BY tblMessauftrag.txtTeilesachnummer, tblMessauftrag.indFOLand, tblMessauftrag.indMessaufgabe
HAVING (((tblMessauftrag.indMessaufgabe)=3)) OR (((tblMessauftrag.indMessaufgabe)=4))
ORDER BY tblMessauftrag.txtTeilesachnummer;

So I have to create another query? Will that takes the space of the disk or reduce the performance?
 

Users who are viewing this thread

Back
Top Bottom