Solved

Need to mark duplicate rows

Posted on 2010-08-12
2
414 Views
Last Modified: 2012-05-10
I need to mark rows in a table that have an ID in the file more than once.  If it is in 3 times then mark it 1,2,3 twice 1,2 once just a 1. can't figure out how to break the count on the id number by grouping using the row_number function any ideas?  mahalo Mark  

0
Comment
Question by:Wonderwall
2 Comments
 
LVL 16

Expert Comment

by:vdr1620
ID: 33423543
0
 
LVL 58

Accepted Solution

by:
cyberkiwi earned 500 total points
ID: 33423630
As a select query

select rn=row_number() over (partition by id order by id), *
from tbl

where rn gives you the "mark" you are after

or as an update if you have a column to hold this value

;with tmp as (
select rn=row_number() over (partition by id order by id), *
from tbl
)
update tmp set targetcol = rn
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

This article will describe one method to parse a delimited string into a table of data.   Why would I do that you ask?  Let's say that you need to pass multiple parameters into a stored procedure to search for.  For our sake, we'll say that we wa…
If you having speed problem in loading SQL Server Management Studio, try to uncheck these options in your internet browser (IE -> Internet Options / Advanced / Security):    . Check for publisher's certificate revocation    . Check for server ce…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

708 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now