select template_no,template_name,template_url,sort_no from external_label_template group by template_no,template_name,template_url,sort_no order by sort_no
<iftest="partNo!= null and partNo != '' and site!= null and site!= ''">
where template_no in (select template_no from external_part_picture where site = #{site} and part_no = #{partNo} and picture_classify = 'ProPicture' group by template_no)
</if>
group by template_no, template_name, template_url, sort_no