Oracle 10g ,the sql throws exception:"not a group by expression"
select count(*)
from (
select h.personal_info_id pid,h.hbsag hbsag,h.sgpt sgpt,MAX(h.date_reported)
from health_checkup_info h
inner join personal_info p on h.personal_info_id = p.id
where
h.deleted = 0
and h.date_reported is not null
and h.hbsag in(1,2)
and p.deleted = 0
group by h.personal_info_id
) t where t.hbsag=1 and t.sgpt>=20
Then, I changed the 'group by' params, add 'h.hbsag' 'h.sgpt', like:
group by h.personal_info_id,h.hbsag,h.sgpt
But the result is not correct.