I have a table with two columns of interest: apc and tid. The same apc can be in a row with multiple tids, and an apc - tid pair can appear multiple times in the database (with different timestamps).
I want to get the apcs with a count of how many unique tids they match with. So for:
apc tid
---------------
abc 012
abc 012
abc 322
def 322
def 432
def 000
I want to get:
apc count
-----------------
abc 2
def 3
I tried doing a group by onapc and tid, but I get all of the duplicates as unique counts (so 3 and 3 above). I tried throwing in distinct in a few places, but that didn't work either.
count(distinct).