I have a table called products.
ProductId| ProductName| ProductType| ProductSize
1 | a | yellow | 12
2 | b | green | 13
3 | c | yellow | 12
4 | d | yellow | 15
________________________________________________
I want to get count of each product as a column at end, where productType, and ProductSize match, the excepted result I want to be..
ProductID|ProductName|ProductType|ProductSize|TotalProduct
1 | a | yellow | 12 | 2
2 | b | green | 13 | 1
3 | c | yellow | 12 | 2
4 | d | yellow | 15 | 1
_________________________________________________________
some what I have try, but failed is look like this.
select ProductId, ProductName, ProductType, ProductSize,
(select count(*) from Product where ProductType=(Products.ProductType) and ProductSize=(products.productSize)) as [TotalProduct] from Products
its return totalProduct = 4 for all the record. thanks