Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > ADO.NET
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 30th, 2004, 04:50 PM
Authorized User
 
Join Date: Sep 2003
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?

Flyin

 
Old April 1st, 2004, 03:57 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi flyin,

ASPFree recently published an article that deals with this:

http://www.aspfree.com/c/a/Database/...ng-of-Records/

Cheers,

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old April 2nd, 2004, 11:30 AM
Authorized User
 
Join Date: Sep 2003
Posts: 93
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to flyin
Default

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

flyin






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





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.