Apurva Singh

Apurva Singh

  • NA
  • 268
  • 56.9k

sum subtract in sql server

Jul 11 2018 7:46 AM
I have a  a select commamd 
 
 
select sd.section_id,Bm.Art,Color,sec.fld_barcode,sec.fld_sectionname,pro_barcode,sd.size,sum(sd.pro_Inqty)-Sum(sd.pro_outqty)as StockInhand from stock_trans_master sm
join stock_trans_details sd
on sm.st_id=sd.st_id
join BarcodeMaster Bm
on Bm.Barcode_m=sd.pro_barcode
join tbl_sectionmaster sec
on sd.section_id=sec.fld_id
where voucherdate <= '11-07-2018 00:00:00'
and (pro_barcode like ''+'%' )
AND (Color like 'S.GREEN' )
AND
(Bm.size like '4' )
AND
(Art like 'AUTUMN' )
and
group by sd.section_id,Bm.Art,sd.size,sec.fld_barcode,sec.fld_sectionname,pro_barcode,Color
 
 This statement return now  all data which stockinhand in equal to 0 value
 
now i want (sd.pro_Inqty)-Sum(sd.pro_outqty)as StockInhand is always return greater than 0 value.
 
 
Please suggest me.
 
 
thanx 

Answers (4)