我有一个包含以下值的表:
Priority Product Supplier
-------------------------
1 ABC JOE'S
2 ABC MOE'S
1 DEF JOE'S
2 DEF MOE'S
结果应该只显示具有最低优先级的Product+Supplier
组合。
1 ABC JOE'S
1 DEF JOE'S
答案 0 :(得分:0)
Select TOP(2) Priority, concat(Product,' ' ,Supplier)
From Table30
Order by Priority ASC
2)
SELECT top 2 Priority,
ISNULL(Product,'') + ' ' + ISNULL(Product,'') as FullName
FROM Table30
Order by Priority ASC
输出
Priority Product Supplier
1 ABC JOE'S
1 DEF JOE'S
答案 1 :(得分:0)
尝试使用SubQuery获取最低优先级
Select Priority, Product, Supplier
From yourTable
Where Priority = ( Select min(Priority) From yourTable )
Order by Product, Supplier