得到以下錯誤:外部引用錯誤,當分組月和年
Each GROUP BY expression must contain at least one column that is not an outer reference
我想有calculatedDrugDistributionHistory
通過facilty,月,年的分組列表。我只想盤點哪些月份已導入系統的設施。
我有這個疑問:
select
f.name,
MONTH(cddh.dateGiven) as 'date_month',
YEAR(cddh.dateGiven) as 'date_year'
from
calculatedDrugDistributionHistory cddh
inner join facilityIndividuals fi on fi.facilityIndividualId = cddh.facilityIndividualId
inner join facilities f on fi.facilityId = f.facilityId
group by
f.name,
'date_month',
'date_year'
order by
f.name,
'date_month',
'date_year'
你正在得到的錯誤是因爲'date_month'和'date_year'一旦這個分組被執行後,就會進入畫面。 –