Howdy, Stranger!

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

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

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
    info@net-allies.de

  • 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.