Count more than 2 for 2 matching fields

  • Thread starter Thread starter D2
  • Start date Start date
D

D2

I must need a brain overhaul, because for some reason the logic of the
following query or queries is eluding me: I have a table with patron names
and numbers (ISSNs of journal titles) among other things. I want a list that
shows the patron names and ISSNs where each has a corresponding count of
two. In other words, a list that shows a certain patron ordered a certain
journal title more than once. Please help!
 
Try something like this:
Select patron,Count(issn)
From table
Where Count(issn) > 2

Tom
 
I must need a brain overhaul, because for some reason the logic of the
following query or queries is eluding me: I have a table with patron names
and numbers (ISSNs of journal titles) among other things. I want a list that
shows the patron names and ISSNs where each has a corresponding count of
two. In other words, a list that shows a certain patron ordered a certain
journal title more than once. Please help!

A Totals query with a HAVING clause will do this:

SELECT PatronName, ISSN, Count(*)
FROM table
GROUP BY PatronName, ISSN
HAVING Count(*) >= 2;

Or use = instead of >= if you want to ignore triplicate orders and
display only duplicate orders.
 
Back
Top