Hello
It has been a while since I have used SQL server and require some help with regards to showing a time difference between a start and end time, with only 1 date to determine these times
SQL
select
Arrival_date
locationdate as LocDate,
locationid as Loc_ID,
locations.loc_name as Location_Name
from current_locations
left outer join locations on
locations.loc_id = current_locations.location_id
where current_locations.Attend_ID = '1234567'
Results
Arrival Date LocDate Loc_ID loc_name
26/02/2013 19:21 26/02/2013 19:27 1270 Queue
26/02/2013 19:21 26/02/2013 19:34 1278 Dept 1
26/02/2013 19:21 26/02/2013 21:10 222 Dept 2
26/02/2013 19:21 27/02/2013 02:56 31 Left Department
What I want to acheive is the following where the Start location date is either the arrival date or the next location date and the endLocDate is the next finish date.
StartLocDate EndLocDate Time Difference Dept
26/02/2013 19:21 26/02/2013 19:27 00/01/1900 00:06 Queue
26/02/2013 19:27 26/02/2013 19:34 00/01/1900 00:07 Dept 1
26/02/2013 19:34 27/02/2013 02:56 00/01/1900 07:22 Dept 2
Can anyone provide some advice on how I would go about achieving this?
Thanks
Helen
It has been a while since I have used SQL server and require some help with regards to showing a time difference between a start and end time, with only 1 date to determine these times
SQL
select
Arrival_date
locationdate as LocDate,
locationid as Loc_ID,
locations.loc_name as Location_Name
from current_locations
left outer join locations on
locations.loc_id = current_locations.location_id
where current_locations.Attend_ID = '1234567'
Results
Arrival Date LocDate Loc_ID loc_name
26/02/2013 19:21 26/02/2013 19:27 1270 Queue
26/02/2013 19:21 26/02/2013 19:34 1278 Dept 1
26/02/2013 19:21 26/02/2013 21:10 222 Dept 2
26/02/2013 19:21 27/02/2013 02:56 31 Left Department
What I want to acheive is the following where the Start location date is either the arrival date or the next location date and the endLocDate is the next finish date.
StartLocDate EndLocDate Time Difference Dept
26/02/2013 19:21 26/02/2013 19:27 00/01/1900 00:06 Queue
26/02/2013 19:27 26/02/2013 19:34 00/01/1900 00:07 Dept 1
26/02/2013 19:34 27/02/2013 02:56 00/01/1900 07:22 Dept 2
Can anyone provide some advice on how I would go about achieving this?
Thanks
Helen