Re: Count vs Distinct

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



That gives me all master records that have more than 1 details record. How
can I expand the statement to get all those master records that have all
detail id's the same?

Ivan

"KARL DEWEY" <KARLDEWEY@xxxxxxxxxxxxxxxxxxxxxxxxx> schrieb im Newsbeitrag
news:1FFAC6B0-396A-4D91-A8A0-46D17A1C0994@xxxxxxxxxxxxxxxx
Try this --
SELECT MasterID.master_ID, MasterID.ID
FROM MasterID
GROUP BY MasterID.master_ID, MasterID.ID
HAVING (((Count(MasterID.ID))>1));


"Ivan Debono" wrote:

Hi all,

I need to create a query based on a master-details tables scenario,
where a
record of the master table can have multiple details records.

For example:
Master Table has 3 records with just 1 field called id (values 1, 2 and
3)

Details table is like this
master_id id
1 10
2 10
2 20
2 30
3 20
3 20

I want to find out because master records have more than 1 detail record
and
those detail records are the same.

From the above details table, master id 1 is not included because it has
just 1 details record. master id 2 has 3 details records but their ids
are
different. Only master id 3 should be returned.

Thanks,
Ivan





.



Relevant Pages

  • Re: Count vs Distinct
    ... It does return all master records that have more than 1 details record. ... "Ivan Debono" wrote: ... I need to create a query based on a master-details tables scenario, ...
    (microsoft.public.access.queries)
  • How to make distinct like this
    ... i have a query between two tables. ... First table has master records, ... Best Regards ... Thomas Seban ...
    (borland.public.delphi.database.ado)
  • Master Detail question
    ... How can I display only those master records that have detail records using ... either table or query? ...
    (borland.public.delphi.database.ado)