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

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Row_Count() double assigning row = 1

Author  Topic 

jameselmore
Starting Member

3 Posts

Posted - 2013-06-13 : 12:49:28
Hello,

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?

MIK_2008
Master Smack Fu Yak Hacker

1054 Posts

Posted - 2013-06-13 : 12:54:15
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.

Cheers
MIK
Go to Top of Page

jameselmore
Starting Member

3 Posts

Posted - 2013-06-13 : 12:58:23
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

jameselmore
Starting Member

3 Posts

Posted - 2013-06-13 : 13:12:57
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
   

- Advertisement -