我想使用CONT_ID参数
连接2个表 select (case when age_years >= 18 and age_years < 30 then '18-29'
when age_years < 50 then '30-49'
when age_years < 70 then '50-69'
when age_years < 100 then '70-100'
end) as age_range,
count(DISTINCT CONT_ID) as num,
SUM(ACAUT) / COUNT(*) as avg
from CLIENT c
left join PAYTB t
on c.CONT_ID = t.CONT_ID
group by (case when age_years >= 18 and age_years < 30 then '18-29'
when age_years < 50 then '30-49'
when age_years < 70 then '50-69'
when age_years < 100 then '70-100'
end)
order by min(age_years);
错误
SQLCODE = -203,错误:对列的参考CONT_ID是不正确的
答案 0 :(得分:1)
您必须在CONT_ID
中指定要使用的列COUNT DISTINCT
。而是做
COUNT(DISTINCT c.CONT_ID)