Re: Count vs Distinct
- From: "Ivan Debono" <ivanmdeb@xxxxxxxxxxx>
- Date: Wed, 19 Apr 2006 13:18:40 +0200
It's half the way though!!
It does return all master records that have more than 1 details record. But
I need all master records where count(details) > 1 AND distinct(details)=1
!!
This means that all the id's of the details for a particular master record
are all the same.
Ivan
"KARL DEWEY" <KARLDEWEY@xxxxxxxxxxxxxxxxxxxxxxxxx> schrieb im Newsbeitrag
news:EEB9A5EC-DEFF-4688-950F-5B83E681082F@xxxxxxxxxxxxxxxx
This does give you all the master records that have multiple detail id'sthe
same.How
"Ivan Debono" wrote:
That gives me all master records that have more than 1 details record.
Newsbeitragcan 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
andnews: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,
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
record3)
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
hasand
those detail records are the same.
From the above details table, master id 1 is not included because it
idsjust 1 details record. master id 2 has 3 details records but their
are
different. Only master id 3 should be returned.
Thanks,
Ivan
.
- Follow-Ups:
- Re: Count vs Distinct
- From: John Spencer
- Re: Count vs Distinct
- References:
- Count vs Distinct
- From: Ivan Debono
- Re: Count vs Distinct
- From: Ivan Debono
- Count vs Distinct
- Prev by Date: Capital letter problem?
- Next by Date: Re: IF AND MID FORMULA DOESNT WORK-WHY??
- Previous by thread: Re: Count vs Distinct
- Next by thread: Re: Count vs Distinct
- Index(es):
Relevant Pages
|