在表中查找唯一值的数量

时间:2021-01-25 04:43:26

I have a table with four columns:

我有一个有四列的表:

PartNumber, ValvePartNumber, ActuatorPartNumber, Price

PartNumber,ValvePartNumber,ActuatorPartNumber,Price

I want to find the number of distinct prices for each combination of ValvePartNumber and ActuatorPartNumber.

我想找到ValvePartNumber和ActuatorPartNumber的每个组合的不同价格的数量。

This is using SQL Server 2005

这是使用SQL Server 2005

1 个解决方案

#1


6  

You can combine COUNT(DISINTCT) and GROUP BY to accomplish this.

您可以组合COUNT(DISINTCT)和GROUP BY来完成此任务。

SELECT ValuePartNumber, ActuatorPartNumber, COUNT(DISTINCT Price) AS Prices
FROM [Table]
GROUP BY ValuePartNumber, ActuatorPartNumber

#1


6  

You can combine COUNT(DISINTCT) and GROUP BY to accomplish this.

您可以组合COUNT(DISINTCT)和GROUP BY来完成此任务。

SELECT ValuePartNumber, ActuatorPartNumber, COUNT(DISTINCT Price) AS Prices
FROM [Table]
GROUP BY ValuePartNumber, ActuatorPartNumber