Select to retrieve the 10 max values - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Select to retrieve the 10 max values

BuxioBuxio Posts: 6Member
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?



Comments

  • SouldrinkerSouldrinker Posts: 143Member
    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:

    [code]
    SELECT NEWS.`news_id`, NEWS.`news_caption`, NEWS.`news_date` FROM NEWS ORDER BY NEWS.`news_date` DESC LIMIT 0,10
    [/code]

    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
    [email protected]

  • gizzugizzu Posts: 42Member
    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?
    :
    :
    :
    :

Sign In or Register to comment.