SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

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

jameselmore
Starting Member

3 Posts

Posted - 06/13/2013 :  12:49:28  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

Pakistan
1050 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.

Cheers
MIK
Go to Top of Page

jameselmore
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

jameselmore
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  
 New 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.06 seconds. Powered By: Snitz Forums 2000