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

  • SEARCH
  • Home
  • 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

Probably I missed something, but lets say I have this: $('a.delete').click(function(){ resp=window.confirm(Are you sure
this is going to drive me mad, because its probably something I have missed
well i have most probably an extremly stupid problem but could not figure it
I have what is probably a really simple, studid question but I can't find
As a novice it's probably something about Ruby I missed, but for the life
This is probably something fundamental and stupid that I've missed, but the various workarounds
This is probably silly but I don't have enough Elisp knowledge to understand what
I have a little problem, probably easy for you. Im using Core Data. I
This is probably a super simple question, but I'm struggling to come up with
This is probably going to be a no, but is there any way I

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.