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
 SQL Server 2008 Forums
 SQL Server Administration (2008)
 SQL QUERY

Author  Topic 

tyekhan
Starting Member

29 Posts

Posted - 2013-05-17 : 07:54:51
I need help with the below query,

SELECT ID, Name, CallDateTime, Num, RC
FROM History
WHERE (CallDateTime > CONVERT(DATETIME, '2013-05-01 00:00:00', 102)) AND (Outcome = 'Called')

Showing the below,
ID Name CallDateTime Num RC
3936803 Name1 01/05/2013 11:16:27 84 Called
5211387 Name2 01/05/2013 12:14:21 604 Called
5185689 Name3 01/05/2013 12:15:28 298 Called
4811923 Name4 01/05/2013 12:29:36 170 Called


This is the query I have at the moment BUT not show how to add two more columns to it they are next called in date & time after the first called in. I want it to show the next time & date does not matter what the RC code is next visit.

So I want mine output to show the below, adding the next called time & date and how many days it take from the first date to the next date,

ID Name CallDateTime Num RC Next CallDateTime Total Number Of Days
3936803 Name1 01/05/2013 11:16 84 Called 04/05/2013 11:16 3
5211387 Name2 01/05/2013 12:14 604 Called 04/05/2013 12:14 3
5185689 Name3 01/05/2013 12:15 298 Called 04/05/2013 12:15 3
4811923 Name4 01/05/2013 12:29 170 Called 04/05/2013 12:29 3


visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-05-17 : 08:03:44
where will you get those values from? are they from other records or is it always constant at 3 days ahead?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

tyekhan
Starting Member

29 Posts

Posted - 2013-05-17 : 09:26:13
No they will not all be 3 days they can be any day, all the Date & times are in the same table with a Unique id Thats called ID.

Only i want is to be able to get the Next day they called in.


quote:
Originally posted by visakh16

where will you get those values from? are they from other records or is it always constant at 3 days ahead?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs


Go to Top of Page
   

- Advertisement -