不正 select c.id as id ,c.name as name ,c.term_st as term_st ,c.term_ed as term_ed ,c.result as result ,c.resultcaption as resultcaption ,tr.cnt as trcnt ,re.cnt as recnt ,hi.cnt as hicnt ,ln.cnt as lncnt ,ro.cnt as rocnt ,de.cnt as decnt ,ek.cnt as ekcnt from (((((((tm_competition c left join (select competition_code,count(id) as cnt from tt_result_trk where status = 1 group by competition_code) tr on c.code = tr.competition_code) left join (select competition_code,count(id) as cnt from tt_result_rel where status = 1 group by competition_code) re on c.code = re.competition_code) left join (select competition_code,count(id) as cnt from tt_result_hig where status = 1 group by competition_code) hi on c.code = hi.competition_code) left join (select competition_code,count(id) as cnt from tt_result_lng where status = 1 group by competition_code) ln on c.code = ln.competition_code) left join (select competition_code,count(id) as cnt from tt_result_rod where status = 1 group by competition_code) ro on c.code = ro.competition_code) left join (select competition_code,count(id) as cnt from tt_result_dec where status = 1 group by competition_code) de on c.code = de.competition_code) left join (select competition_code,count(id) as cnt from tt_result_eki where status = 1 group by competition_code) ek on c.code = ek.competition_code) where c.status = 1 and c.term_st >= '-2-04-01' and c.term_st <= '-1-03-31' and ( ( tr.cnt is not null or re.cnt is not null or hi.cnt is not null or ln.cnt is not null or ro.cnt is not null or de.cnt is not null or ek.cnt is not null ) or c.result <> '' ) order by term_st desc,term_ed desc,showorder desc