Ross Goddard
Ross Goddard

Reputation: 4302

Find Number of Unique Values in 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

Upvotes: 1

Views: 458

Answers (1)

Jonathan Lonowski
Jonathan Lonowski

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

Related Questions