DECLARE count_1 number := 5000; Count_2 number:= 1000 ; beginIF (count_1< (SELECT count(*) FROM staff n WHERE n.category = 16 GROUP BY n.category) and (Count_2 < (SELECT count(*) FROM staff n<pre lang="text"> WHERE n.category in (2,3) GROUP BY n.category))) then select category,count_1 as count from staff where category in (1,2,3); else (count_1 > (SELECT count(*) FROM staff n WHERE n.category = 1 GROUP BY n.category) and (Count_2< (SELECT count(*) FROM staff n WHERE n.category in (2,3) GROUP BY n.category))) --then select category,count_1 as count from staff where category in (1,2,3); end if; end;