sql语句: if OBJECT_ID('tempDB..#THFH')<>0 drop table #THFH select a.code,a.setdepot_id,d.depotid,c1.clothingid,c.styleid,b.nums,COUNT(TMID) smNUMS into #THFH from u_outindentset a left join u_outindentsetsub b on a.id=b.code left join u_outindentsetstyle f on b.style_code = f.id left join b_style c on f.style_id=c.id left join B_Clothing c1 on b.clothing_id=c1.id left join b_depot d on a.depot_id=d.id left join F100_Label.dbo.tm_formlist e on b.clothing_id=e.clothing_id and a.id=e.code --left join t18_tmlist e on b.clothingid=e.clothingid and a.outindentid=e.tmlistid where a.setdepot_id in ('${id}') --d.depotid = '25371013'and and a.sure='1' and a.states = '2' and a.sure_date>='${begin}' --and a.sure_date>='2020-01-01' and a.sure_date-1<'${end}' --and a.sure_date-1<'2020-12-01' and d.depotid='11203' group by a.code,a.setdepot_id,d.depotid,c1.clothingid,c.styleid,b.nums
select a.code,a.depotid,b.s_name,a.clothingid,a.styleid,nums,smNUMS from #THFH a left join b_depot b on a.setdepot_id=b.id where nums>smNUMS select distinct id,s_name from b_depot where st_area in ('${name}') and depotid not like '25371%' and LEN(depotid)=8 and (depotid like '21%' or depotid like '51%' or depotid like '61%' or depotid like '23%' or depotid like '2T%' or depotid like '5T%' or depotid like '6T%' ) select distinct a.name from b_looksub a left join b_depot b on a.name=b.st_area where depotid not like '25371%' and (depotid like '21%' or depotid like '51%' or depotid like '61%' or depotid like '23%' or depotid like '2T%' or depotid like '5T%' or depotid like '6T%' ) and a.code = '2006' |