Author |
Topic |
naidu4u
Starting Member
23 Posts |
Posted - 2010-11-01 : 19:25:03
|
I tried create a table with the data in it...[code="sql"]create table mytable( changeid int,refotsid int,OTtime datetime,Oldtype varchar(20),Oldlocal varchar(50),newtype varchar(20),newlocal varchar(50),DateChanged datetime,DateClosed datetime)[/code]inserting the rows in it...[code="sql"]insert into mytable (Changeid, refotsid, OTtime, Oldtype, Oldlocal, newtype, newlocal, DateChanged, DateClosed)select '77397', '48242','10/29/2010 11:50:00 AM','Decision', '10/30/2010 6:00:00 AM', 'Parts', '16.00', '10/30/2010 9:08:00 AM', '10/31/2010 10:50:00 AM'union allselect '77422', '48242', '10/29/2010 11:50:00 AM', 'Parts', '16.00', 'Decision', '10/30/2010 1:00:00 PM','10/30/2010 2:13:00 PM', '10/31/2010 10:50:00 AM'union allselect '77432', '48242', '10/29/2010 11:50:00 AM', 'Decision', '10/30/2010 1:00:00 PM', 'Parts', '08.00', '10/30/2010 3:53:00 PM', '10/31/2010 10:50:00 AM'union allselect '77470', '48242', '10/29/2010 11:50:00 AM', 'Parts', '08.00', 'Solid', '10/31/2010 6:00:00 AM', '10/30/2010 11:20:00 PM', '10/31/2010 10:50:00 AM'union allselect '77352', '48226', '10/29/2010 3:00:00 AM', 'Decision', '10/29/2010 6:00:00 PM', 'Decision', '10/30/2010 4:00:00 AM', '10/29/2010 10:58:00 PM', '10/31/2010 4:20:00 PM'union allselect '77394', '48226', '10/29/2010 3:00:00 AM', 'Decision', '10/30/2010 4:00:00 AM', 'Solid', '10/30/2010 2:00:00 PM', '10/30/2010 9:03:00 AM', '10/31/2010 4:20:00 PM'union allselect '77444', '48226', '10/29/2010 3:00:00 AM', 'Solid', '10/30/2010 2:00:00 PM', 'Solid', '10/30/2010 8:00:00 PM', '10/30/2010 5:45:00 PM', '10/31/2010 4:20:00 PM'union allselect '77472', '48226', '10/29/2010 3:00:00 AM', 'Solid', '10/30/2010 8:00:00 PM', 'Solid', '10/31/2010 4:00:00 AM', '10/31/2010 12:03:00 AM', '10/31/2010 4:20:00 PM'union all select '77488', '48226', '10/29/2010 3:00:00 AM', 'Solid', '10/31/2010 4:00:00 AM', 'Solid', '10/31/2010 10:00:00 AM', '10/31/2010 8:03:00 AM', '10/31/2010 4:20:00 PM'[/code]Now I need a new column XYZ in which lets take for the samerefotsid = 48242 then for the first row I need XYZ as the dimediff(minute, DateChanged, OTtime)where as from the second row I need XYZ as datediff(minute, DateChanged of prev row, DateChanged of present row)and again for the next refotsid the same thing and so on...hope this is clear and if not please let me know I will try something else....Thanks in advance.... |
|
X002548
Not Just a Number
15586 Posts |
|
naidu4u
Starting Member
23 Posts |
Posted - 2010-11-01 : 20:34:04
|
for any refotsid for the first row XYZ should be a datediff(minute, DateChanged, OTtime)and for the remaining rows in the same refotsid, XYZ should be datediff(minute, DateChanged of prev row, DateChange of current row)Thanks in advance.... |
|
|
|
|
|