我正在尝试获取两个日期之间的平均月数差异:
select client_id,
avg(12*(year(MAX(received_date))-year(min(received_date)))
+ MONTH(MAX(received_date))-MONTH(min(received_date)))
from tmpTwoAccessions
group by CLIENT_ID,PATIENT_ID
我收到这条消息:
Cannot perform an aggregate function on an expression containing an aggregate or a subquery.
你能告诉我我在这里做错了什么吗?非常感谢您的指导。