mardi 20 octobre 2015

Count unique rows

Im having this problem where im trying to count the number of entries by a unique value.

SELECT table1.PID, table2.CID

FROM table1 

INNER JOIN table2 using (OID)

WHERE table1.PID IN (
    SELECT table1.PID
    FROM table1 
    JOIN table2 using (OID)
    WHERE table2.CID = 'A'
) AND table2.CID != 'A'

what I would like to do is to count the number of unique table2.CID entries.

NOTE: I need to do the grouping cause of duplicate values.

Just to help, here is a picture of the table i'm getting as an output. What I would like to have is the count of each name on unique ID values. So ERNSH should return 7 and not 15.

enter image description here

Aucun commentaire:

Enregistrer un commentaire