Help with query

  • Thread starter TotallyConfused
  • Start date
T

TotallyConfused

Can someone please explain this query? Thank you.

SELECT A.[DR CNTY], A.[DR ID], A.[DR NAME], A.[DR PH], A.[DR FX], B.[DR PH],
B.[DR FX]
FROM [Main TRKG TBL] AS A INNER JOIN [Main TRKG TBL1] AS B ON A.ID = B.ID
GROUP BY A.[DR CNTY], A.[DR ID], A.[DR NAME], A.[DR PH], A.[DR FX], B.[DR
PH], B.[DR FX]
HAVING (((B.[DR PH])<>[A].[DR PH])) OR (((B.[DR FX])<>[A].[DR FX]))
ORDER BY A.[DR CNTY], A.[DR NAME];
 
J

John Spencer

It appears you have two tables and are trying to find records where DR PH in
the first table is not equal to DR PH in the second table or Where DR FX is
not equal to DR FX in the second table.

It also appears that you are trying to group the results so you return only
one record for these conditions being true. HOWEVER, assuming that A.ID
(and B.ID) are unique values in the two tables I can see no reason for
grouping the results.

I would expect that you would get the same results with the following query.

SELECT A.[DR CNTY], A.[DR ID], A.[DR NAME]
, A.[DR PH], A.[DR FX], B.[DR PH], B.[DR FX]
FROM [Main TRKG TBL] AS A INNER JOIN [Main TRKG TBL1] AS B
ON A.ID = B.ID
WHERE (((B.[DR PH])<>[A].[DR PH])) OR (((B.[DR FX])<>[A].[DR FX]))
ORDER BY A.[DR CNTY], A.[DR NAME];

--
John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County
..
 

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