PHP Code:
SQLselect from t1 ;

LO_ID      SO_ID      MO_ID
---------- ---------- ----------
412A       412B       412A
412B       412A       412A
412C       412C       412D
412D       412D       412D

  1  select lo_id
,
  
2         (select count(*) from t1 where so_id a.lo_idct1,
  
3         (select count(*) from t1 where mo_id a.lo_idct2
  4
from   t1 a
SQL
> /

LO_ID             CT1        CT2
---------- ---------- ----------
412A                1          2
412B                1          0
412C                1          0
412D                1          2

SQL
spool off

Is this you are looking for?

If the answer is correct, I will try to write ANALYTIC QUERY.

Tamil