我有一个包含四列的表格:
PartNumber,ValvePartNumber,ActuatorPartNumber,Price
我想找到ValvePartNumber和ActuatorPartNumber的每个组合的不同价格数。
这是使用SQL Server 2005
答案 0 :(得分:6)
您可以合并COUNT(DISINTCT)
和GROUP BY
来完成此任务。
SELECT ValuePartNumber, ActuatorPartNumber, COUNT(DISTINCT Price) AS Prices
FROM [Table]
GROUP BY ValuePartNumber, ActuatorPartNumber