Re: Counting distinct elements

2002-06-07 Thread David M. Peak
Depends. If this is a correlation table and the combined columns are a primary key, SELECT ObjId, COUNT(ElemId) FROMElems GROUP BY ElemId; if the combination is not unique, then: SELECT ObjId, COUNT(DISTINCT ElemId) FROMElems GROUP BY ElemId; - Origin

Re: Counting distinct elements

2002-06-07 Thread Gerald Clark
You mean SELECT ObjId,ElemId,count( distinct Objid,ElemId ) from Elems group by ObjId; ? Csaba Gabor wrote: >Seems like this should be an easy question, but I just don't get it: > >If I have CREATE TABLE Elems (ObjId INT, ElemId INT); >Is there a nice query to find the Number of Distinct Ele