Re: Count vs Distinct
- From: "Ivan Debono" <ivanmdeb@xxxxxxxxxxx>
- Date: Tue, 18 Apr 2006 17:16:52 +0200
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 --where a
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,
3)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
and
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
arethose 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
different. Only master id 3 should be returned.
Thanks,
Ivan
.
- References:
- Count vs Distinct
- From: Ivan Debono
- Count vs Distinct
- Prev by Date: Re: Query SQL not working..
- Next by Date: Re: joining 2 fields into 1
- Previous by thread: Re: Count vs Distinct
- Next by thread: Re: Count vs Distinct
- Index(es):
Relevant Pages
|