Hi,
I am close to making this work
I have this table
attending_res_name actcase_start_datetime minutes
S_X 7/1/2017 8
S_X 7/1/2017 7
S_Y 7/7/2017 6
S_Y 7/7/2017 10
I am trying get the following result
Surgeon date total minutes
S_x 7/1/2017 15
S_Y 7/7/2017 16
Here is what I did so far
SELECT casemain.attending_res_name, SUM(DATEDIFF(n, caseintraop.pat_or_in_datetime, caseintraop.pat_or_out_datetime)) AS Minutes, casemain.actcase_start_datetime,
CAST(dateAdded AS date)
FROM casemain INNER JOIN
caseintraop ON casemain.casemain_id = caseintraop.casemain_id
WHERE (casemain.actcase_start_datetime BETWEEN CONVERT(DATETIME, '2017-02-01 00:00:00', 102) AND CONVERT(DATETIME, '2017-03-01 00:00:00', 102))
GROUP BY CAST(dateAdded AS date), casemain.attending_res_name, CAST(casemain.actcase_start_datetime AS date), casemain.actcase_start_datetime
thank you in advance
I am close to making this work
I have this table
attending_res_name actcase_start_datetime minutes
S_X 7/1/2017 8
S_X 7/1/2017 7
S_Y 7/7/2017 6
S_Y 7/7/2017 10
I am trying get the following result
Surgeon date total minutes
S_x 7/1/2017 15
S_Y 7/7/2017 16
Here is what I did so far
SELECT casemain.attending_res_name, SUM(DATEDIFF(n, caseintraop.pat_or_in_datetime, caseintraop.pat_or_out_datetime)) AS Minutes, casemain.actcase_start_datetime,
CAST(dateAdded AS date)
FROM casemain INNER JOIN
caseintraop ON casemain.casemain_id = caseintraop.casemain_id
WHERE (casemain.actcase_start_datetime BETWEEN CONVERT(DATETIME, '2017-02-01 00:00:00', 102) AND CONVERT(DATETIME, '2017-03-01 00:00:00', 102))
GROUP BY CAST(dateAdded AS date), casemain.attending_res_name, CAST(casemain.actcase_start_datetime AS date), casemain.actcase_start_datetime
thank you in advance