2009-04-15 2 views
1

함께 계산 I 오라클 DB에서 (간체) 다음과 같은 테이블이 있습니다최대는 SQL 쿼리

productId | modelDescription 
     1 |    thing 
     2 |  another thing 
     3 |  not a thing 
     4 |    thing 

내가이 테이블에서 가장 높은 성상이있는 modeldescription을 선택합니다을. 문제는 거의 무한한 모델 설명이있을 수 있다는 것입니다. 그래서 결과 집합은 다음과 같이 같아야합니다 : 또한

modelDescription | appearance 
      thing |   2 
    another thing |   1 
      ... |  ... 
+0

가장 높은 외모는 productId별로 정렬 된 것 중에서 가장 높은 것입니까? –

답변

3
select modeldescription, count(modeldescription) 
from products 
group by modeldescription 
order by 2 desc 
+0

thaks 정확히 내가 뭘 찾고 있었어 thats – Red33mer

1

, 당신 만이 가장 높은 다음 추가하려는 경우 :

선택 최고 1 modeldescription ......