Reputation: 4302
I have a table with four columns:
PartNumber, ValvePartNumber, ActuatorPartNumber, Price
I want to find the number of distinct prices for each combination of ValvePartNumber and ActuatorPartNumber.
This is using SQL Server 2005
Upvotes: 1
Views: 458
Reputation: 123463
You can combine COUNT(DISINTCT)
and GROUP BY
to accomplish this.
SELECT ValuePartNumber, ActuatorPartNumber, COUNT(DISTINCT Price) AS Prices
FROM [Table]
GROUP BY ValuePartNumber, ActuatorPartNumber
Upvotes: 6