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
 Cursor issues
 New Topic  Reply to Topic
 Printer Friendly
Previous Page
Author Previous Topic Topic Next Topic
Page: of 3

rmg1
Constraint Violating Yak Guru

256 Posts

Posted - 02/04/2013 :  04:34:23  Show Profile  Reply with Quote
Anyone?
Please?
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52323 Posts

Posted - 02/04/2013 :  04:43:15  Show Profile  Reply with Quote
can there be more than one record for a user with CallEventTypeID of 26 within same group ie not separated by another user in between?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

rmg1
Constraint Violating Yak Guru

256 Posts

Posted - 02/04/2013 :  06:24:50  Show Profile  Reply with Quote
Unfortunately, yes.
All I need is the last dispositionID that is not null for each user group (so if the same user access the call several times with other people in between I'd need one line for each time they left a disposition ID).

Hopefully that makes sense.

I'd hoped the alter your original code slightly so that it took into account the disposition IDs as well, but that didn't work very well.
Go to Top of Page

rmg1
Constraint Violating Yak Guru

256 Posts

Posted - 02/05/2013 :  07:41:53  Show Profile  Reply with Quote
Anyone any joy with this one?
Please?
Go to Top of Page

James K
Flowing Fount of Yak Knowledge

3712 Posts

Posted - 02/05/2013 :  07:46:10  Show Profile  Reply with Quote
I would like to help, rmg1, but I sort of lost track of this thread. I know I had proposed something earlier in the thread, but then it got away from me, so I don't know what the current state is. Perhaps it might be useful to start a new thread restating the problem with some sample data, sample code that is easily consumed, and the results you expect to see.
Go to Top of Page

rmg1
Constraint Violating Yak Guru

256 Posts

Posted - 02/05/2013 :  08:22:21  Show Profile  Reply with Quote
Hi james

I didn't want to start a new thread as this is a continuation of same issue.
I'll repost data and expected results here:-
quote:

CallId CallEventID StartTime UserId CallEventTypeId CallEventModifiedAt CallTypeID CallEventId2 ToCallPriorityId DispositionId Received Call_Priority PCCallEventID
43625860 1 2013-02-02 00:04:15.070 12175 11 2013-02-02 00:04:15.070 1 NULL NULL NULL 2013-02-02 00:04:15.070 NULL NULL
43625860 2 2013-02-02 00:04:15.070 12175 5 2013-02-02 00:04:15.137 1 NULL NULL NULL 2013-02-02 00:04:15.070 NULL NULL
43625860 7 2013-02-02 00:04:15.070 12175 25 2013-02-02 00:08:41.817 1 NULL 4 NULL 2013-02-02 00:04:15.070 3 NULL
43625860 11 2013-02-02 00:04:15.070 12175 6 2013-02-02 00:13:27.970 1 NULL NULL NULL 2013-02-02 00:04:15.070 NULL NULL
43625860 12 2013-02-02 00:04:15.070 12175 23 2013-02-02 00:13:27.970 1 NULL NULL NULL 2013-02-02 00:04:15.070 NULL NULL
43625860 13 2013-02-02 00:04:15.070 11331 24 2013-02-02 02:14:59.503 1 NULL NULL NULL 2013-02-02 00:04:15.070 NULL NULL
43625860 14 2013-02-02 00:04:15.070 11331 5 2013-02-02 02:14:59.503 1 NULL NULL NULL 2013-02-02 00:04:15.070 NULL NULL
43625860 15 2013-02-02 00:04:15.070 11331 26 2013-02-02 02:16:33.487 1 NULL NULL 35 2013-02-02 00:04:15.070 NULL NULL
43625860 16 2013-02-02 00:04:15.070 11331 27 2013-02-02 02:16:33.487 1 NULL NULL NULL 2013-02-02 00:04:15.070 NULL NULL
43625860 17 2013-02-02 00:04:15.070 11331 6 2013-02-02 02:16:37.280 1 NULL NULL NULL 2013-02-02 00:04:15.070 NULL NULL
43625860 18 2013-02-02 00:04:15.070 11331 23 2013-02-02 02:16:37.280 1 NULL NULL NULL 2013-02-02 00:04:15.070 NULL NULL
43625860 19 2013-02-02 00:04:15.070 11331 24 2013-02-02 02:56:28.373 1 NULL NULL NULL 2013-02-02 00:04:15.070 NULL NULL
43625860 20 2013-02-02 00:04:15.070 11331 5 2013-02-02 02:56:28.373 1 NULL NULL NULL 2013-02-02 00:04:15.070 NULL NULL
43625860 21 2013-02-02 00:04:15.070 11331 26 2013-02-02 02:57:40.600 1 NULL NULL 37 2013-02-02 00:04:15.070 NULL NULL
43625860 22 2013-02-02 00:04:15.070 11331 27 2013-02-02 02:57:40.600 1 NULL NULL NULL 2013-02-02 00:04:15.070 NULL NULL
43625860 24 2013-02-02 00:04:15.070 11331 6 2013-02-02 02:57:48.180 1 NULL NULL NULL 2013-02-02 00:04:15.070 NULL NULL
43625860 25 2013-02-02 00:04:15.070 11331 36 2013-02-02 02:57:48.180 1 NULL NULL NULL 2013-02-02 00:04:15.070 NULL NULL


(Apologies for the formatting)

What I want to get from the above is:-
CallID - 43625860
User ID - 11331
CallEventModifiedAt - 2013-02-02 02:57:40.600 (i.e. the last time a Disposition was added)
DispositionID - 37

All this needs to be on one record (I'm trying to put it into a temp table for further processing)

All I need is the last Disposition ID for each user for each session along with the CallID, time and UserID.

Another example:-
quote:

CallId CallEventID StartTime UserId CallEventTypeId CallEventModifiedAt CallTypeID CallEventId2 ToCallPriorityId DispositionId Received Call_Priority PCCallEventID
43625904 1 2013-02-02 00:00:53.523 12952 11 2013-02-02 00:00:53.523 13 NULL NULL NULL 2013-02-02 00:00:53.523 NULL NULL
43625904 2 2013-02-02 00:00:53.523 12952 5 2013-02-02 00:00:53.587 13 NULL NULL NULL 2013-02-02 00:00:53.523 NULL NULL
43625904 9 2013-02-02 00:00:53.523 12952 26 2013-02-02 00:10:37.867 13 NULL NULL 592 2013-02-02 00:00:53.523 NULL NULL
43625904 10 2013-02-02 00:00:53.523 12952 27 2013-02-02 00:10:37.867 13 NULL NULL NULL 2013-02-02 00:00:53.523 NULL NULL
43625904 11 2013-02-02 00:00:53.523 12952 25 2013-02-02 00:10:37.980 13 NULL 2 NULL 2013-02-02 00:00:53.523 1 NULL
43625904 12 2013-02-02 00:00:53.523 12952 113 2013-02-02 00:11:03.903 13 NULL NULL NULL 2013-02-02 00:00:53.523 NULL NULL
43625904 13 2013-02-02 00:00:53.523 12952 26 2013-02-02 00:14:28.363 13 NULL NULL 56 2013-02-02 00:00:53.523 NULL NULL
43625904 14 2013-02-02 00:00:53.523 12952 6 2013-02-02 00:14:34.347 13 NULL NULL NULL 2013-02-02 00:00:53.523 NULL NULL
43625904 15 2013-02-02 00:00:53.523 12952 23 2013-02-02 00:14:34.347 13 NULL NULL NULL 2013-02-02 00:00:53.523 NULL NULL
43625904 16 2013-02-02 00:00:53.523 2656 24 2013-02-02 00:15:13.627 13 NULL NULL NULL 2013-02-02 00:00:53.523 NULL NULL
43625904 17 2013-02-02 00:00:53.523 2656 5 2013-02-02 00:15:13.627 13 NULL NULL NULL 2013-02-02 00:00:53.523 NULL NULL
43625904 18 2013-02-02 00:00:53.523 2789 49 2013-02-02 00:19:35.660 13 NULL NULL NULL 2013-02-02 00:00:53.523 NULL NULL
43625904 20 2013-02-02 00:00:53.523 2656 26 2013-02-02 00:24:34.030 13 NULL NULL 40 2013-02-02 00:00:53.523 NULL NULL
43625904 21 2013-02-02 00:00:53.523 2656 27 2013-02-02 00:24:34.030 13 NULL NULL NULL 2013-02-02 00:00:53.523 NULL NULL
43625904 22 2013-02-02 00:00:53.523 2656 6 2013-02-02 00:24:43.003 13 NULL NULL NULL 2013-02-02 00:00:53.523 NULL NULL
43625904 23 2013-02-02 00:00:53.523 2656 23 2013-02-02 00:24:43.003 13 NULL NULL NULL 2013-02-02 00:00:53.523 NULL NULL
43625904 25 2013-02-02 00:00:53.523 2656 24 2013-02-02 00:42:14.990 13 NULL NULL NULL 2013-02-02 00:00:53.523 NULL NULL
43625904 26 2013-02-02 00:00:53.523 2656 5 2013-02-02 00:42:14.990 13 NULL NULL NULL 2013-02-02 00:00:53.523 NULL NULL
43625904 27 2013-02-02 00:00:53.523 2656 26 2013-02-02 00:43:17.670 13 NULL NULL 364 2013-02-02 00:00:53.523 NULL NULL
43625904 28 2013-02-02 00:00:53.523 2656 27 2013-02-02 00:43:17.670 13 NULL NULL NULL 2013-02-02 00:00:53.523 NULL NULL
43625904 29 2013-02-02 00:00:53.523 2656 48 2013-02-02 00:44:52.683 13 NULL NULL NULL 2013-02-02 00:00:53.523 NULL NULL
43625904 31 2013-02-02 00:00:53.523 2656 26 2013-02-02 00:47:16.017 13 NULL NULL 364 2013-02-02 00:00:53.523 NULL NULL
43625904 32 2013-02-02 00:00:53.523 2656 27 2013-02-02 00:47:16.017 13 NULL NULL NULL 2013-02-02 00:00:53.523 NULL NULL
43625904 33 2013-02-02 00:00:53.523 2656 6 2013-02-02 00:47:25.827 13 NULL NULL NULL 2013-02-02 00:00:53.523 NULL NULL
43625904 34 2013-02-02 00:00:53.523 2656 23 2013-02-02 00:47:25.827 13 NULL NULL NULL 2013-02-02 00:00:53.523 NULL NULL
43625904 35 2013-02-02 00:00:53.523 3658 49 2013-02-02 00:51:16.897 13 NULL NULL NULL 2013-02-02 00:00:53.523 NULL NULL
43625904 37 2013-02-02 00:00:53.523 3658 49 2013-02-02 01:13:46.337 13 NULL NULL NULL 2013-02-02 00:00:53.523 NULL NULL
43625904 39 2013-02-02 00:00:53.523 2656 24 2013-02-02 01:25:50.893 13 NULL NULL NULL 2013-02-02 00:00:53.523 NULL NULL
43625904 40 2013-02-02 00:00:53.523 2656 5 2013-02-02 01:25:50.893 13 NULL NULL NULL 2013-02-02 00:00:53.523 NULL NULL
43625904 44 2013-02-02 00:00:53.523 2656 26 2013-02-02 01:37:26.273 13 NULL NULL 423 2013-02-02 00:00:53.523 NULL NULL
43625904 45 2013-02-02 00:00:53.523 2656 27 2013-02-02 01:37:26.273 13 NULL NULL NULL 2013-02-02 00:00:53.523 NULL NULL
43625904 49 2013-02-02 00:00:53.523 2656 6 2013-02-02 01:37:38.633 13 NULL NULL NULL 2013-02-02 00:00:53.523 NULL NULL
43625904 50 2013-02-02 00:00:53.523 2656 36 2013-02-02 01:37:38.633 13 NULL NULL NULL 2013-02-02 00:00:53.523 NULL NULL


(Same apology as above).

From this one, I'd expect to see:-
Record 1
CallID - 43625904
User ID - 12952
CallEventModifiedAt - 2013-02-02 00:14:28.363
DispositionID - 56

Record 2
CallID - 43625904
User ID - 2656
CallEventModifiedAt - 2013-02-02 00:47:16.017
DispositionID - 364

Record 3
CallID - 43625904
User ID - 2656
CallEventModifiedAt - 2013-02-02 01:37:26.273
DispositionID - 423

For this one, there is a user between the two UserIDs 2656 but without a Disposition ID so I can quite safely ignore it.

I'd be grateful for any assistance.

Go to Top of Page

James K
Flowing Fount of Yak Knowledge

3712 Posts

Posted - 02/05/2013 :  09:28:22  Show Profile  Reply with Quote
If I am going in circles please tell me, but referring to the two data sets that you posted:

In the first example, why don't you want disposition ID = 35 at 2013-02-02 02:16:33.487

Or, if that is because you want to pick up only the latest disposition ID, in the second dataset, why are you picking up 364 and 423 for User ID - 2656 (but ignoring disposition id 40 at 2013-02-02 00:24:34.030)
Go to Top of Page

rmg1
Constraint Violating Yak Guru

256 Posts

Posted - 02/05/2013 :  09:38:44  Show Profile  Reply with Quote
Hi James

I'm ignoring disposition ID 35 in the first set as it's superseded by 37 in the same "patch" for that user.
It's the same with the second dataset. Disposition ID 40 is superseded by 364 at 2013-02-02 00:47:16.017 in the same "patch".

I just want the last DispositionID for each user for each slot (if that makes sense).
Go to Top of Page

James K
Flowing Fount of Yak Knowledge

3712 Posts

Posted - 02/05/2013 :  09:59:00  Show Profile  Reply with Quote
What is the column that lets me identify if something belongs to the same patch (or slot)?
Go to Top of Page

rmg1
Constraint Violating Yak Guru

256 Posts

Posted - 02/06/2013 :  02:17:01  Show Profile  Reply with Quote
Hi james

It's the grouping of UserIDs by the CallEventModifiedAt column.
If you sort the data by CallEventModifiedAt, it will give the UserIDs in the order they accessed that record.
For every change of User ID I want the last DispositionID for that user (if that makes sense?)
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52323 Posts

Posted - 02/06/2013 :  02:29:13  Show Profile  Reply with Quote
if you can provide data in easy consumable format (ie as insert statements) i'll make a try. just dont have time to build a data population script and work on it

see guidelines here

http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

rmg1
Constraint Violating Yak Guru

256 Posts

Posted - 02/06/2013 :  03:19:02  Show Profile  Reply with Quote
Hopefully I've done this right. I've scripted the table as a CREATE and then done the insert afdterwards.

create table #original_crystal1 (
    CallId varchar(15)
    ,CallEventID int
    ,StartTime datetime
    ,UserId int
    ,CallEventTypeId int
    ,CallEventModifiedAt datetime
	,CallTypeID int
    ,CallEventId2 int
	,ToCallPriorityId float
    ,DispositionId int
	,[Received] datetime
	,Call_Priority varchar(5)
	,PCCallEventID int
)
insert into #original_crystal1(
	CallId
	,CallEventID
	,StartTime
	,UserId
	,CallEventTypeId
	,CallEventModifiedAt
	,CallTypeID
	,CallEventId2
	,ToCallPriorityId
	,DispositionId
	,Received
	,Call_Priority
	,PCCallEventID
	)
select 43625904,1,'2013-02-02 00:00:53.523',12952,11,'2013-02-02 00:00:53.523',13,NULL,NULL,NULL,'2013-02-02 00:00:53.523',NULL,NULL union all
select 43625904,2,'2013-02-02 00:00:53.523',12952,5,'2013-02-02 00:00:53.587',13,NULL,NULL,NULL,'2013-02-02 00:00:53.523',NULL,NULL union all
select 43625904,9,'2013-02-02 00:00:53.523',12952,26,'2013-02-02 00:10:37.867',13,NULL,NULL,592,'2013-02-02 00:00:53.523',NULL,NULL union all
select 43625904,10,'2013-02-02 00:00:53.523',12952,27,'2013-02-02 00:10:37.867',13,NULL,NULL,NULL,'2013-02-02 00:00:53.523',NULL,NULL union all
select 43625904,11,'2013-02-02 00:00:53.523',12952,25,'2013-02-02 00:10:37.980',13,NULL,2,NULL,'2013-02-02 00:00:53.523',1,NULL union all
select 43625904,12,'2013-02-02 00:00:53.523',12952,113,'2013-02-02 00:11:03.903',13,NULL,NULL,NULL,'2013-02-02 00:00:53.523',NULL,NULL union all
select 43625904,13,'2013-02-02 00:00:53.523',12952,26,'2013-02-02 00:14:28.363',13,NULL,NULL,56,'2013-02-02 00:00:53.523',NULL,NULL union all
select 43625904,15,'2013-02-02 00:00:53.523',12952,23,'2013-02-02 00:14:34.347',13,NULL,NULL,NULL,'2013-02-02 00:00:53.523',NULL,NULL union all
select 43625904,14,'2013-02-02 00:00:53.523',12952,6,'2013-02-02 00:14:34.347',13,NULL,NULL,NULL,'2013-02-02 00:00:53.523',NULL,NULL union all
select 43625904,16,'2013-02-02 00:00:53.523',2656,24,'2013-02-02 00:15:13.627',13,NULL,NULL,NULL,'2013-02-02 00:00:53.523',NULL,NULL union all
select 43625904,17,'2013-02-02 00:00:53.523',2656,5,'2013-02-02 00:15:13.627',13,NULL,NULL,NULL,'2013-02-02 00:00:53.523',NULL,NULL union all
select 43625904,18,'2013-02-02 00:00:53.523',2789,49,'2013-02-02 00:19:35.660',13,NULL,NULL,NULL,'2013-02-02 00:00:53.523',NULL,NULL union all
select 43625904,21,'2013-02-02 00:00:53.523',2656,27,'2013-02-02 00:24:34.030',13,NULL,NULL,NULL,'2013-02-02 00:00:53.523',NULL,NULL union all
select 43625904,20,'2013-02-02 00:00:53.523',2656,26,'2013-02-02 00:24:34.030',13,NULL,NULL,40,'2013-02-02 00:00:53.523',NULL,NULL union all
select 43625904,23,'2013-02-02 00:00:53.523',2656,23,'2013-02-02 00:24:43.003',13,NULL,NULL,NULL,'2013-02-02 00:00:53.523',NULL,NULL union all
select 43625904,22,'2013-02-02 00:00:53.523',2656,6,'2013-02-02 00:24:43.003',13,NULL,NULL,NULL,'2013-02-02 00:00:53.523',NULL,NULL union all
select 43625904,25,'2013-02-02 00:00:53.523',2656,24,'2013-02-02 00:42:14.990',13,NULL,NULL,NULL,'2013-02-02 00:00:53.523',NULL,NULL union all
select 43625904,26,'2013-02-02 00:00:53.523',2656,5,'2013-02-02 00:42:14.990',13,NULL,NULL,NULL,'2013-02-02 00:00:53.523',NULL,NULL union all
select 43625904,27,'2013-02-02 00:00:53.523',2656,26,'2013-02-02 00:43:17.670',13,NULL,NULL,364,'2013-02-02 00:00:53.523',NULL,NULL union all
select 43625904,28,'2013-02-02 00:00:53.523',2656,27,'2013-02-02 00:43:17.670',13,NULL,NULL,NULL,'2013-02-02 00:00:53.523',NULL,NULL union all
select 43625904,29,'2013-02-02 00:00:53.523',2656,48,'2013-02-02 00:44:52.683',13,NULL,NULL,NULL,'2013-02-02 00:00:53.523',NULL,NULL union all
select 43625904,32,'2013-02-02 00:00:53.523',2656,27,'2013-02-02 00:47:16.017',13,NULL,NULL,NULL,'2013-02-02 00:00:53.523',NULL,NULL union all
select 43625904,31,'2013-02-02 00:00:53.523',2656,26,'2013-02-02 00:47:16.017',13,NULL,NULL,364,'2013-02-02 00:00:53.523',NULL,NULL union all
select 43625904,33,'2013-02-02 00:00:53.523',2656,6,'2013-02-02 00:47:25.827',13,NULL,NULL,NULL,'2013-02-02 00:00:53.523',NULL,NULL union all
select 43625904,34,'2013-02-02 00:00:53.523',2656,23,'2013-02-02 00:47:25.827',13,NULL,NULL,NULL,'2013-02-02 00:00:53.523',NULL,NULL union all
select 43625904,35,'2013-02-02 00:00:53.523',3658,49,'2013-02-02 00:51:16.897',13,NULL,NULL,NULL,'2013-02-02 00:00:53.523',NULL,NULL union all
select 43625904,37,'2013-02-02 00:00:53.523',3658,49,'2013-02-02 01:13:46.337',13,NULL,NULL,NULL,'2013-02-02 00:00:53.523',NULL,NULL union all
select 43625904,40,'2013-02-02 00:00:53.523',2656,5,'2013-02-02 01:25:50.893',13,NULL,NULL,NULL,'2013-02-02 00:00:53.523',NULL,NULL union all
select 43625904,39,'2013-02-02 00:00:53.523',2656,24,'2013-02-02 01:25:50.893',13,NULL,NULL,NULL,'2013-02-02 00:00:53.523',NULL,NULL union all
select 43625904,45,'2013-02-02 00:00:53.523',2656,27,'2013-02-02 01:37:26.273',13,NULL,NULL,NULL,'2013-02-02 00:00:53.523',NULL,NULL union all
select 43625904,44,'2013-02-02 00:00:53.523',2656,26,'2013-02-02 01:37:26.273',13,NULL,NULL,423,'2013-02-02 00:00:53.523',NULL,NULL union all
select 43625904,50,'2013-02-02 00:00:53.523',2656,36,'2013-02-02 01:37:38.633',13,NULL,NULL,NULL,'2013-02-02 00:00:53.523',NULL,NULL union all
select 43625904,49,'2013-02-02 00:00:53.523',2656,6,'2013-02-02 01:37:38.633',13,NULL,NULL,NULL,'2013-02-02 00:00:53.523',NULL,NULL
Go to Top of Page

James K
Flowing Fount of Yak Knowledge

3712 Posts

Posted - 02/06/2013 :  08:11:31  Show Profile  Reply with Quote
rmg1, thank you for posting that script. See if this gives you the results you are looking for. For testing purposes, I used OUTER APPLY which will give you instances where there are no DispositionID's also. If you want only the 3 rows which have non-null DispositionID, change the OUTER APPLY to a CROSS APPLY
;WITH cte AS
(
	SELECT
		ROW_NUMBER() OVER (PARTITION BY CallId ORDER BY CallEventModifiedAt)-
		ROW_NUMBER() OVER (PARTITION BY CallId,UserId ORDER BY CallEventModifiedAt) AS GroupId,
		*
	FROM
		#original_crystal1
)
SELECT
	a.CallId,
	a.UserId,
	b.CallEventModifiedAt,
	b.DispositionID
FROM
	(SELECT DISTINCT a.CallId, a.UserId, a.GroupId FROM cte a) AS a
	OUTER APPLY
	(
		SELECT TOP (1) b.CallEventModifiedAt,b.DispositionID
		FROM cte b
		WHERE b.GroupId = a.GroupId AND b.UserId = a.UserId AND a.CallId = b.CallId
			AND b.DispositionID IS NOT NULL 
		ORDER BY CallEventModifiedAt DESC 
	)b;
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52323 Posts

Posted - 02/06/2013 :  10:37:06  Show Profile  Reply with Quote
Another way without use of CTE


SELECT CallId,
	UserId,
	CallEventModifiedAt,
	DispositionID
FROM
(
SELECT *,ROW_NUMBER() OVER (PARTITION BY CallId,UserId,NextDt ORDER BY CASE WHEN DispositionId IS NOT NULL THEN 1 ELSE 0 END DESC,CallEventModifiedAt DESC) AS Seq
FROM #original_crystal1 c
OUTER APPLY (SELECT MIN(CallEventModifiedAt) AS NextDt
             FROM #original_crystal1
             WHERE CallId = c.CallId
             AND UserId<> c.UserId
             AND CallEventModifiedAt > c.CallEventModifiedAt
             )c1
 --WHERE DispositionID IS NOT NULL
)t
WHERE Seq=1
ORDER BY CallEventModifiedAt



output
-------------------------------------------------
CallId	UserId	CallEventModifiedAt	DispositionID	NextDt
------------------------------------------------------------------------------------
43625904	12952	2013-02-02 00:14:28.363	56	2013-02-02 00:15:13.627
43625904	2656	2013-02-02 00:15:13.627	NULL	2013-02-02 00:19:35.660
43625904	2789	2013-02-02 00:19:35.660	NULL	2013-02-02 00:24:34.030
43625904	2656	2013-02-02 00:47:16.017	364	2013-02-02 00:51:16.897
43625904	3658	2013-02-02 01:13:46.337	NULL	2013-02-02 01:25:50.893
43625904	2656	2013-02-02 01:37:26.273	423	NULL



If you want only records with DispositionID not null uncomment line in blue above

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Edited by - visakh16 on 02/06/2013 10:39:05
Go to Top of Page
Page: of 3 Previous Topic Topic Next Topic  
Previous Page
 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.11 seconds. Powered By: Snitz Forums 2000