Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Jun 2006
    Location
    UK
    Posts
    892
    Thanks
    301
    Thanked 2 Times in 2 Posts

    Question ASP- SQL Server..Query help....

    Hello,

    I am using ASP and MS SQL Sever 2000 as backend database..

    I am writing a SQL query which will pick up top 5 recipes details who have scored the highest marks from the following table

    tblrecipes -

    Code:
     ID |  recipe_name | Total
    The following points to be noted:

    - The table has 500 records.
    - 50 of them have achieved the highest marks ie 100 marks each
    - My following query is picking up top 5 records who have scored 100 marks

    Code:
    SELECT TOP 5 ID, total, recipe_name
    FROM tblrecipes 
    ORDER BY total DESC
    and getting this output:




    Now my question is:

    On what basis its showing up this sequence of listing? I mean why the ID 89 is on the top and 136 at the bottom? Why the ID is not the other way round?

    Like the following?

    ID
    __
    178
    136
    89
    286
    340


    Can someone explain please?


    Thanx

  • #2
    Senior Coder
    Join Date
    Nov 2002
    Location
    North-East, UK
    Posts
    1,265
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You have only specified one ORDER BY field. AFAIK after ordering by that field the rest of the order will be random.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •