944,056 Members | Top Members by Rank

Ad:
  • ASP Discussion Thread
  • Unsolved
  • Views: 2440
  • ASP RSS
Jan 31st, 2007
0

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

Expand Post »
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 -

ASP Syntax (Toggle Plain Text)
  1. 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

ASP Syntax (Toggle Plain Text)
  1. SELECT TOP 5 ID, total, recipe_name
  2. FROM tblrecipes
  3. ORDER BY total DESC

and getting this output:

http://img2.freeimagehosting.net/uploads/3d14a5272a.jpg


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
Similar Threads
Reputation Points: 58
Solved Threads: 1
Posting Whiz in Training
cancer10 is offline Offline
234 posts
since Dec 2004
Feb 2nd, 2007
0

Re: ASP- SQL Server..Query help....

Try
ASP Syntax (Toggle Plain Text)
  1. SELECT TOP 5 ID, total, recipe_name
  2. FROM tblrecipes
  3. ORDER BY total DESC, ID DESC

The thing is that you haven't manetioned to sort the ID colums as well. So IDs appear in the order of last modified data/time.
Reputation Points: 9
Solved Threads: 1
Junior Poster in Training
msaqib is offline Offline
91 posts
since Sep 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP Forum Timeline: Where can I get a Library of std ASP functions
Next Thread in ASP Forum Timeline: error '80020009' Exception occurred.





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC