View Single Post
  #4  
Old March 4th, 2010, 01:58 PM posted to microsoft.public.access.queries
John Spencer
external usenet poster
 
Posts: 7,815
Default challenging query

This query would identify all cases where code field had more than one price.

SELECT CodeField
FROM Table
GROUP BY CodeField
HAVING Min(Price) Max(Price)

So you could use something like the following to identify the records. The
only exceptions would be if you had one record for a code field with a price
and one or more records for that code field with no price (null).
SELECT *
FROM [SomeTable]
WHERE [CodeField] IN
(SELECT [CodeField]
FROM [SomeTable]
GROUP BY [CodeField]
HAVING Min([Price]) Max([Price]))

Post back if you need further help in building the query. If needed you can
handle nulls by modifying the having clause to read like the following.
HAVING Min(Nz(Price,0)) Max(Nz(Price,0))


John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County

Pellissier wrote:
I have a table with a code field and a price field.
I need to find records where the code field data is the same (I did a
duplicate query)

Now I need to make a report that shows those duplicates but only if the
price field is different.

I am trying to show where there are duplicate codes that have different prices