
select
    pcb.id
    ,count(pcb.total_component_count) as count
from ks_inspection_result.t_result_aoi_pcb pcb
group by pcb.id

select
    pcb.id
     ,wfmi.array_value
    ,count(wfmi.pcb_id) as count
from ks_inspection_result.t_result_aoi_pcb pcb
left join ks_inspection_result.t_aoi_whole_wfmi_result wfmi
    on pcb.id = wfmi.pcb_id
group by pcb.id, wfmi.array_value
having count(wfmi.pcb_id) > 0 and wfmi.array_value > 0
pcb.id로 먼저 묶이고, wfmi.array_value로 한번 더 묶인다.

select
    pcb.id
     ,wfmi.array_value as arrayNum
    ,count(wfmi.pcb_id) as count
from ks_inspection_result.t_result_aoi_pcb pcb
left join ks_inspection_result.t_aoi_whole_wfmi_result wfmi
    on pcb.id = wfmi.pcb_id
group by pcb.id, wfmi.array_value
having count(wfmi.pcb_id) > 0 and wfmi.array_value > 0
order by count desc
order By절에서 집계함수절을 사용할수 있다.
