January 5, 2011 at 7:27 pm
Okay, how about adding a column to this data to count the first, second, third, etc occurrence of duplicate PA_EnterpriseID's in column 1 - Placing the count in a new column:
PA_EnterpriseIDPP_NamePP_ID, *Occurrence*
91st Quarter 2010 Remove from PIP Agency Pruning132, 1
93rd Quarter 2009 PIP Agency Pruning112, 2
92nd Quarter 2009 PIP Agency Pruning104, 3
91st Quarter 2009 PIP Agency Pruning 102, 4
93rd Quarter 2008 PIP Agency Pruning98, 5
10Bonus Commission Plan (BCP) 200883, 1
10College World Series Sales Contest 200869, 2
10Bainwest63, 3
10Bonus Commission Plan (BCP) 200761, 4
10NASCAR 200755, 5
10Seminars - 200751, 6
Please - Someone help me! 🙁
January 5, 2011 at 8:11 pm
Check out this article on SQL Server Ranking Functions[/url]. It looks like the ROW_NUMBER() function will do what you're after.
Wayne
Microsoft Certified Master: SQL Server 2008
Author - SQL Server T-SQL Recipes
January 6, 2011 at 2:49 am
photonicman (1/5/2011)
Okay, how about adding a column to this data to count the first, second, third, etc occurrence of duplicate PA_EnterpriseID's in column 1 - Placing the count in a new column:PA_EnterpriseIDPP_NamePP_ID, *Occurrence*
91st Quarter 2010 Remove from PIP Agency Pruning132, 1
93rd Quarter 2009 PIP Agency Pruning112, 2
92nd Quarter 2009 PIP Agency Pruning104, 3
91st Quarter 2009 PIP Agency Pruning 102, 4
93rd Quarter 2008 PIP Agency Pruning98, 5
10Bonus Commission Plan (BCP) 200883, 1
10College World Series Sales Contest 200869, 2
10Bainwest63, 3
10Bonus Commission Plan (BCP) 200761, 4
10NASCAR 200755, 5
10Seminars - 200751, 6
Please - Someone help me! 🙁
Try it out
select *,row_number() over (partition by PA_EnterpriseID order by PA_EnterpriseID) from tablename
Pramod
SQL Server DBA | MCSE SQL Server 2012/2014
in.linkedin.com/in/pramodsingla/
http://pramodsingla.wordpress.com/
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply