Home arrow static arrow Java Programming [Archive] - Sort by numbers
Warning: Creating default object from empty value in /www/htdocs/w008deb8/wiki/components/com_staticxt/staticxt.php on line 51
Java Programming [Archive] - Sort by numbers
This topic has 3 replies on 1 page.

Posts:54
Registered: 1/19/04
Sort by numbers  
Aug 9, 2004 8:13 AM



 
I'm doing a simple program to get the best selling item from a sales database. Is there any method to sort those sales by the quantity?

Thanks.
 

Posts:458
Registered: 7/1/03
Re: Sort by numbers  
Aug 9, 2004 8:15 AM (reply 1 of 3)



 
Try looking at the Comparable interface.

You give so little information that I cant possibly help you further.
 

Posts:11,186
Registered: 06.04.04
Re: Sort by numbers  
Aug 9, 2004 8:21 AM (reply 2 of 3)



 
I'm doing a simple program to get the best selling item from a sales database. Is there any method to
sort those sales by the quantity?

If you're talking JDBC here, why not add a clause 'ORDER BY DESCENDING QUANTITY' (or similar) and
let the database do the work for you? All you need to do then is retrieve the first row to get your best
selling item ...

kind regards,

Jos
 

Posts:11,200
Registered: 7/22/99
Re: Sort by numbers  
Aug 9, 2004 10:07 AM (reply 3 of 3)



 
or better yet, 'HAVING quantity = MAX(quantity)' which returns only the rows with the highest quantity (if several).
 
This topic has 3 replies on 1 page.