[英]SQL Query to get distinct results from one table and match those results to the another column in the table
I have an SQL table with product names in one column and a product category in another column.我有一个 SQL 表,其中一列包含产品名称,另一列包含产品类别。 So each product belongs to a specific category.
所以每个产品都属于一个特定的类别。 I am trying to figure out an sql command that will return distinct values from the product name column but will also display the product category each product belongs to.
我试图找出一个 sql 命令,它将从产品名称列返回不同的值,但也会显示每个产品所属的产品类别。 Any ideas?
有任何想法吗?
你可以这样试试
SELECT Distinct([ProductName]),[ProductCategeory] FROM [DB].[dbo].[tblProduct]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.