Top 10 list in SQL Server

Results 1 to 2 of 2

Thread: Top 10 list in SQL Server

  1. #1
    Join Date
    Dec 1969

    Default Top 10 list in SQL Server

    Good afternoon Ladies and Gentlemen,<BR><BR>I wonder if anyone might be able to help with the a query that I am trying<BR>to write to enable me to display a top 10 list of most connected clients on<BR>my website.<BR><BR>I have a table in my SQL server database called &#039;Logging&#039;. The time spent<BR>online by each member is recorded in the &#039;LoggedTime&#039; field of my database.<BR>The time entered in this numeric field is stored in seconds. For example a<BR>connection for 60 seconds would have the value &#039;60&#039; in the logged time field<BR>of the Logging table. Each new connection is stored in this table. A member<BR>could have from 0 to unlimited entries in this table.<BR><BR>What I need my query to do is firstly group all connections to each member<BR>and then select the top 10 entries from that list.<BR><BR>Does anyone have a way of doing this as I am completely clueless.<BR><BR>Thanks very much in advance.<BR><BR>--<BR>Adrian Foot<BR>Grenadier Guards<BR>Potential Officer<BR><BR>Tel: 07958 619703<BR>Email:

  2. #2
    Join Date
    Dec 1969

    Default RE: Top 10 list in SQL Server

    <BR>select top 10 member, sum(LoggedTime) as totalConnectTime<BR>from logging<BR>group by member<BR>order by totalConnectTime desc<BR>

Posting Permissions

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