My table looks like this:
ID ProductName ProductCode 1 abc 123 2 abc 123 3 abc 456 4 def 789 5 ghi 246 6 jkl 369 7 jkl 369 8 jkl 369 9 jkl 468 10 jkl 468
And I want to create a pivot table that looks like this:
ProductName ProductCode Total abc 123 2 abc 456 1 jkl 369 3 jkl 468 2
In other words, I am not interested in the products "def" and "ghi" because they appear only once in the source table. For everything else, I want to make a group by ProductName and ProductCode and display the numbers.
I tried playing with group by clauses and where in (select ...), but I just ended circles in circles.
The table has about 50,000 rows and is located on SQL Server 2008 R2.
immyh source share