At 10:19 -0600 2/1/02, Paul DuBois wrote:
>At 15:56 +0000 2/1/02, SED wrote:
>>Hi,
>>
>>I'm trying to make a query where I select something distinct ordered by
>>most frequent?
>>
>>I found below example from the manual but I can not figure out how I
>>should order them by most frequent - do you know how?
>>
>> SELECT DISTINCT owner FROM pet
>
>Don't use distinct in that case. Count them and order by the descending
>counts.
>
>SELECT owner, COUNT(owner) AS frequency FROM pet ORDER BY frequency DESC;
Oops. Forgot the GROUP BY:
SELECT owner, COUNT(owner) AS frequency FROM pet
GROUP BY owner, ORDER BY frequency DESC;
>
>>
>>Regards,
>>SED

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.