I wonder how can I put in one condition having and for example:
select count(s.id) from card c
join subject s on c.ean=s.ean
join account a on s.id=a.owner_subject
where a.status_external=0
and a.status_internal=0
and s.type=0
having(
( trunc(max(s.hist_modified_tmsp))<=last_day(add_months(trunc(sysdate,'mm'),-1)) and level=1 )
or
( trunc(min(s.hist_modified_tmsp))<=last_day(add_months(trunc(sysdate,'mm'),-1)) and level=2 ) )
My Oracle tells me "Not a GROUP BY Expression". Any ideas please? I will be very grateful for any help, thank you
Having
begins a clause similar towhere
(except applied after aggregation (e.g. sums) instead of before), so you can only have it once in the query like this:Also you need a
group by
clause specifying the columns that the query groups by: