Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6062341
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:02:21+00:00 2026-05-23T09:02:21+00:00

I have probably missed something simple with my problem. However its like me to

  • 0

I have probably missed something simple with my problem. However its like me to overlook any small details. But I have been searching for a while now and havent come across anything similar to my issue.

Setup:
SQL 2005, Stored Procedure.

I have a table that is updated frequently with call attempts. Using a UNIQUEIDENTIFIER to tie all the records together i.e.

xxx-xxx-xxx-xxx-xxxx | 20/06/2011 12:00 | 10

I want to have a stored procedure that Grabs all the records, and sorts them by the UNIQUEIDENTIFIER and at the same time, producing a counter for the attempts. i.e.

1111-1111-1111-1111    | 20/06/2011 12:05    |  10 | 0    
1111-1111-1111-1111    | 20/06/2011 12:06    |  30 | 1   
2222-2222-2222-2222    | 20/06/2011 12:10    | 120 | 0  
3333-3333-3333-3333    | 20/06/2011 12:20    |  50 | 0

From the above it should be simple to be able to to indentify the call attempts and add on the number. However im probably being very silly.

Any help is appreciated.

Regards
Chris

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T09:02:22+00:00Added an answer on May 23, 2026 at 9:02 am

    You can use ROW_NUMBER.

    e.g.

    SELECT ID, DateField, FieldA, 
        ROW_NUMBER() OVER(PARTITION BY ID ORDER BY DateField ASC) AS Counter
    FROM YourTable
    ORDER BY ID, DateField
    

    The PARTITION BY basically resets the counter for each distinct ID and the following ORDER BY ensures the counter is assigned incrementally ordered by the Date field. Note this will be a counter starting from 1 each time. If you want it to start from 0, you can just subtract 1 in the SELECT

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

There is probably is simple fix for this but I currently have code similar
This probably has a simple answer, but I must not have had enough coffee
I'm a newbie with WPF and c# and have a (probably very simple) problem.
I'm looking at a new computer which will probably have vista on it. But
This probably sounds really stupid but I have noo idea how to implement jquery's
This is probably a really stupid MSBuild question but if I have <ItemGroup> <Dll
This is probably not possible, but I have this class: public class Metadata<DataType> where
I have probably simple question: /the code: http://jsfiddle.net/FZufj/8/ / I have a simple code
I have an initialization class that preloads content into a variable (probably a list
I have stumbled in this phrase in the web: C# is probably not the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.