需要格式为 yyyy-mm 的日期,并且应该分组以获取计数,但是当我给出
group by date is says invalid
我找到了这个解决方案
谁能通过提供其他解决方案来帮助我
select
count(*) as count,
Convert(char(10), RH.updated_datetime, 105) as date,
SUM(
datediff(SECOND,
PRI.procedure_performed_datetime ,RH.updated_datetime
)
)/count(*) as average_reporting_tat
from
report R,
report_history RH,
study S,
procedure_runtime_information PRI,
priorities PP,
patient P,
"procedure" PR
where
RH.report_fk=R.pk and RH.pk IN (
select pk from (
select * from report_history where report_fk=r.pk
) as result
where old_status_fk IN (21, 27)
) AND R.study_fk = S.pk
AND S.procedure_runtime_fk = PRI.pk
AND PRI.procedure_fk = PR.pk
AND S.priority_fk = PP.pk
AND PRI.patient_fk = P.pk
AND RH.updated_datetime >= '2012-05-01'
AND RH.updated_datetime <= '2013-09-12'
group by Convert(char(10), RH.updated_datetime, 105)