当我运行下面的查询时,我收到以下消息:
SQL 错误:ORA-00904:“B”。“MEMBERS_COUNT”:无效标识符 00904。00000 -“%s:无效标识符”
select pt.paym_type_name, pt.dvd_allowed, b.members_count
from payment_type pt
where paym_type_id in (select paym_type_id
from (SELECT paym_type_id,
count(paym_type_id) as members_count
FROM user_payment
WHERE (paym_type_id=1 OR
paym_type_id=2 OR
paym_type_id=3) AND
SYSDATE <= (ADD_MONTHS(paym_date, 12) )
GROUP BY paym_type_id
ORDER BY MEMBERS_COUNT DESC) b
where rownum=1)
;
我不明白为什么。我该如何解决?我确实需要在末尾添加 MEMBERS_COUNT 列。