I want to find all duplicate occurrences of UPCs. For me, UPCs can be in one table or another, so I have to do an UNION ALL. The problem is that once I do that, I can no longer effectively count the UPCs. What I want is to list the UPCs and the amount of times that they occur. But I get an error message. This is my sample data. I feel like I'm close to it, but it's not working.Declare @Temp1 Table( Sku nvarchar(100) ,UPC nvarchar(100) )Insert into @Temp1 Values('ABCD','61345')Insert into @Temp1 Values('EBCD','72345')Insert into @Temp1 Values('FBCD','52345')Insert into @Temp1 Values('SBCD','22345')Declare @Temp2 Table( Sku nvarchar(100) ,UPC nvarchar(100) )Insert into @Temp2 Values('ASDF','61345')Insert into @Temp2 Values('BSDF','52343')Insert into @Temp2 Values('CSDF','52345')Insert into @Temp2 Values('DSDF','72343')Select UPCFrom @Temp1UNION ALLSelect UPCFrom @Temp2GROUP BY (UPC)HAVING COUNT(UPC)>1
-SergioI use Microsoft SQL 2008