Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > .NET > Other .NET > ADO.NET
Password Reminder
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ADO.NET For discussion about ADO.NET.  Topics such as question regarding the System.Data namespace are appropriate.  Questions specific to a particular application should be posted in a forum specific to the application .
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ADO.NET section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 30th, 2004, 04:50 PM
Authorized User
Join Date: Sep 2003
Location: , , .
Posts: 93
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to flyin
Default Query to populate top users

Hi everyone,

I'm having a problem with a query and was wondering of anyone knows the trick to this ad-hoc query.

Basically I am trying to find the top 10 users of my site, but the part i want to do is to have SQL return me back a "Rank" field that will by itself, increment itself.

Like for instance in a query, you can do something such as

"Select 1 AS Rank, AccountID FROM Score" and this will return two fields, one for accountID's and one field named Rank which equals 1.

Well what i want is to somehow:

Select TOP 10 Rank as Rank+1, AccountID FROM Score ORDER BY Score DESC"

I know that the "Rank as Rank+1" isn't correct syntax, that's the part i'm trying to find which will increment itself from 1 to 10 for each record somehow. any thoughts?


Reply With Quote
  #2 (permalink)  
Old April 1st, 2004, 03:57 AM
Imar's Avatar
Wrox Author
Points: 72,022, Level: 100
Points: 72,022, Level: 100 Points: 72,022, Level: 100 Points: 72,022, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,076
Thanks: 80
Thanked 1,587 Times in 1,563 Posts

Hi flyin,

ASPFree recently published an article that deals with this:




Imar Spaanjaars
Everyone is unique, except for me.
Reply With Quote
  #3 (permalink)  
Old April 2nd, 2004, 11:30 AM
Authorized User
Join Date: Sep 2003
Location: , , .
Posts: 93
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to flyin

thanks imar, that's a great lead. works great!!


Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Top percent Query acting strangely in access 2002 jeremy1048 Access 4 January 15th, 2008 09:27 AM
Populate Array with SQL query string nicoleh Classic ASP Databases 3 July 6th, 2005 02:55 PM
Join Query Distinct and Top 1 ahanson SQL Language 4 November 30th, 2004 01:29 PM
Users selection driven search query... mat41 Classic ASP Databases 3 November 16th, 2004 03:14 AM
Crystal reports 10.0 Query about showing top N rec rajdotme Crystal Reports 1 June 12th, 2004 03:35 AM

All times are GMT -4. The time now is 01:29 AM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.