I'm pretty sure I've done this before, but can't remember how I did it. What I need to do is get a sum of minutes (proc_duration) within a set time frame. So for the first field pictured below I want it to add all of the proc_durations where LN Child 65M BHP match. So if I have 2 120's and a 60 it would show a total of 300 if that makes sense and have it do that for all of the fields. Thank you in advance. SQL Server 2005.
select
pct.clinic_id,
pct.service_id,
pct.program_id,
pct.protocol_id,
sum(pct.proc_duration)
from patient_clin_tran pct
where (pct.proc_chron between '2011-12-22' and '2014-12-22')
group by pct.clinic_id, pct.service_id, pct.program_id, pct.protocol_id, pct.proc_duration
Aucun commentaire:
Enregistrer un commentaire