--查样品单 部位重复(方法一,需要1分钟左右)
select Style_stru_SampleList.splno as 样品单号, Style_stru_SampleList.style_no as 型体号
,Style_stru_SampleList.part_no, style_part.part_nm,count(Style_stru_SampleList.part_no) as 重复数量 from Style_stru_SampleList ,style_part
where Style_stru_SampleList.style_no != '' and Style_stru_SampleList.part_no != '' and Style_stru_SampleList.part_no=style_part.part_no
group by Style_stru_SampleList.splno,Style_stru_SampleList.style_no,Style_stru_SampleList.part_no,style_part.part_nm
having count(Style_stru_SampleList.part_no) >1
order by Style_stru_SampleList.style_no,Style_stru_SampleList.part_no
--查样品单 部位重复(方法二,只需要几秒钟)
select a.splno,a.style_no,a.part_no,b.part_nm,a.dnum from( select splno,style_no /* as 型体号 */ ,part_no /*as 部位代号 */
,count(part_no) as Dnum /*重复数量 */ from style_stru_SampleList
where style_no!='' and part_no!=''
group by splno,style_no,part_no having count(part_no) >1 ) a ,style_part b where b.part_no=a.part_no
order by a.style_no,a.part_no
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/729024/viewspace-564845/ ,如需转载,请注明出处,否则将追究法律责任。