Select query help
On Sun, 25 Apr 2010 22:50:01 -0400, MikeR wrote:
I have tblLog. It's fields a
Call: text
Freq: single
Mode: text
CID: text
QSL_R: text
Credited: T/F
I need the SQL to return all records where 'Credited' is false, 'QSL_R' NULL or
blank, and whose combination of 'Freq' and 'Mode' for a given 'CID' have 'Credited' =
false, but not if that record has a 'mate' whose 'CID', 'Freq/Mode', 'QSL_R' all
match, and 'Credited' is True.
A Query such as
SELECT * FROM tblLog
WHERE [Credited] = False
AND [QSL_R] IS NOT NULL
AND ([Credited] = FALSE AND NOT EXISTS (SELECT [Call] FROM tblLog AS X
WHERE X.Call = tblLog.Call
AND X.Credited = True));
should work. The NOT EXISTS clause may be slow, and could probably be replaced
by a JOIN but I'd need to mock up a table to test it.
--
John W. Vinson [MVP]
|