sql - How to Count Duplicate Values in One Table? -
i have view following table/sample values:
parentid, childcontainerid, childid 1 ccid1 cid1 1 ccid1 cid2 1 ccid2 cid1 1 ccid2 cid2 1 ccid2 cid3 2 ccid3 cid1 2 ccid3 cid2 2 ccid3 cid2 2 ccid4 cid5 2 ccid4 cid2 2 ccid5 cid5
my goal craft query return duplicate child's across parent id (disregarding childcontainerid)
so example data above following result
parentid, childid, countchildid 1 cid1 2 2 cid2 3 2 cid5 2
i've tried number of different queries aren't working , think i'm frustrated , overlooking simple @ point.
any ideas?
select parentid, chilid, count(*) countchildid yourtable group parentid, chilid having count(*) > 1
Comments
Post a Comment