MySQL

Moderators: Jonathan
Number of threads: 259
Number of posts: 514

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Select to retrieve the 10 max values Posted by Buxio on 31 Oct 2002 at 12:21 PM
am rather a newbie...but i was wonder what select statement i can use to retreieve the 10 top values from a table...for instance the 10 books that sell the most.... whit the largest numbers for noofsales

Select title, author, price, noofsales where noofsales between ????

if use between i need 2 values the MAX(noofsales) that would give me one value for the between..how do i find the 10 value?

or is there another select one could use?



Report
Re: Select to retrieve the 10 max values Posted by Souldrinker on 4 Nov 2002 at 11:51 PM
ok... here an example:

Guess you want to select the 10 most actual news from out a table "NEWS" with the following fields:

news_id
news_caption
news_date

To do so, you need the following statement:

SELECT NEWS.`news_id`, NEWS.`news_caption`, NEWS.`news_date` FROM NEWS ORDER BY NEWS.`news_date` DESC LIMIT 0,10


That's all... this script will retrieve the 10 most actual news, do so with other tables - it depends deeply on the order clause.
best regards,

sebastian mohrenstecher
executive secretary
net::allies

www.net-allies.de
info@net-allies.de

Report
Re: Select to retrieve the 10 max values Posted by gizzu on 6 Jan 2003 at 5:04 AM
Try this:

Select top 10 title, author, price, noofsales order by noofsales desc









: am rather a newbie...but i was wonder what select statement i can use to retreieve the 10 top values from a table...for instance the 10 books that sell the most.... whit the largest numbers for noofsales
:
: Select title, author, price, noofsales where noofsales between ????
:
: if use between i need 2 values the MAX(noofsales) that would give me one value for the between..how do i find the 10 value?
:
: or is there another select one could use?
:
:
:
:




 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.