Find the number of unique values ​​in a table

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

+1


source to share


1 answer


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

      

+6


source







All Articles