Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Row_Count() double assigning row = 1
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Starting Member

3 Posts

Posted - 06/13/2013 :  12:49:28  Show Profile  Reply with Quote

I believe I'm using this function correctly but for every new partition of my data it assigns the first two rows a row number of one... This is what I currently have as my query:

select a.callid, left(b.agent_id,9) as agent_id, b.RLA_datetime, a.answtime, a.disptime, on_off, Row_number() over (partition by agent_id order by a.disptime) rownum
into #onetwo
from #one a join #two
ON b.connid = a.callid AND a.agentext = left(b.dn,5) AND b.agent_id IS NOT NULL
ORDER BY agent_id asc, disptime asc

What could I be doing wrong?

Flowing Fount of Yak Knowledge

1054 Posts

Posted - 06/13/2013 :  12:54:15  Show Profile  Reply with Quote
yup and thats what partitioning needs to do. For agent_ID=1 and dispTime Acending the sequence will be created and soon the Agent_ID is changed a new sequence will be created.

Go to Top of Page

Starting Member

3 Posts

Posted - 06/13/2013 :  12:58:23  Show Profile  Reply with Quote
No, what I'm saying is it will make 2 rownum = 1 in the same sequence..

It looks something like this
Agent_ID rownum
1 1
1 1
1 2
1 3
2 1
2 1
2 2
2 3
2 4

I'm clear on what it SHOULD be doing, but it's not doing what it should
Go to Top of Page

Starting Member

3 Posts

Posted - 06/13/2013 :  13:12:57  Show Profile  Reply with Quote
I figured it out.

I'm calculating the row numbers as the table is being joined and the method which creates the rownumbers is being computed during the joining process or something, so it's coming up with a lot of weird things. I joined to a temp table and then made added the row numbers in a seperate query
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.02 seconds. Powered By: Snitz Forums 2000