Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

numbering repetaed records 12 123 1 1234 etc sql ms 2005

Posted on 2008-10-16
5
197 Views
Last Modified: 2010-03-19
I have a table with n records (1 field each) I nee an sqk query that will order them by field and add a consecutive number to each repeted record starting from 1 then 2 then 3 ..until the next different record(field) is reached abd star againnwith 1,2 123,1, etc

Ex
John 1
John 2
Mike 1
Sam  1
Sam 2
Sam 3
0
Comment
Question by:robrodp
  • 3
  • 2
5 Comments
 
LVL 39

Accepted Solution

by:
BrandonGalderisi earned 500 total points
ID: 22736714
This should do:

select YourField, row_number() over (partition by YourField order by yourField) from YourTable

0
 

Author Comment

by:robrodp
ID: 22736801
select email row_number() over (partition by email order by email) from icrea

I get this error:

Incorrect syntax near ')'.
0
 
LVL 39

Expert Comment

by:BrandonGalderisi
ID: 22736861
you forgot the comma between email and row_number()
0
 
LVL 39

Expert Comment

by:BrandonGalderisi
ID: 22736868
and the reason it is giving an error is because it thinks you are trying to alias email as row_number
0
 

Author Comment

by:robrodp
ID: 22736910
Got it....

Sorry
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Mysql Left Join Case 10 70
SQL - format decimal in a string 5 39
MYSQL responding very slow 3 24
What is this datetime? 1 20
Data architecture is an important aspect in Software as a Service (SaaS) delivery model. This article is a study on the database of a single-tenant application that could be extended to support multiple tenants. The application is web-based develope…
In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question