2016-12-08 4 views
-3

의 최소값은 나는 다음과 같은 값으로 테이블이 있습니다.SQL 서버 :</p> <pre><code>Priority Product Supplier ------------------------- 1 ABC JOE'S 2 ABC MOE'S 1 DEF JOE'S 2 DEF MOE'S </code></pre> <p>이 결과는 가장 우선 순위가 낮은 <code>Product+Supplier</code> 조합을 표시해야합니다 : 테이블

1 ABC JOE'S 
1 DEF JOE'S 
+1

이 포스트가 제로 도시 노력 또는 연구에 참여하십시오. – dfundako

+0

http://stackoverflow.com/help/how-to-ask 앞으로 도움이 될 것입니다. –

답변

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 
0

가 최소 우선 순위를 얻기 위해 서브 쿼리를 사용하여 시도

Select Priority, Product, Supplier 
From yourTable 
Where Priority = (Select min(Priority) From yourTable) 
Order by Product, Supplier