create procedure LTS_QC_GOODS_QUANTITY
@date1 datetime,
@date2 datetime,
@week varchar(20)
as
begin
select
b.branch_code,
b.branch_desc,
Gd.product_no_string,
s.sizes_desc,
c.colour_desc,
sum(gd.quantity_received) Qty_received,
--Sum(Ph.Stock_units_QC) as QC_Quantity,
Sum(gd.quantity_received*pd.current_sp) as Current_SP
from
goodsreceive_master gm,
goodsreceive_det gd,
branch b,
product_detail pd,
colour c, sizes s
--oduct_history ph
where gm.authorised_date between @date1 and @date2
and gm.goods_rec_id = gd.goods_rec_id
and gd.sku_id = pd.sku_id
and pd.colour_id =c.colour_id
and pd.sizes_id = s.sizes_id
and product_no_string = Gd.product_no_string
and b.branch_id = gm.warehouse_id
--and gd.sku_id = ph.sku_id
and gd.quantity_received > 0
--and branch_code = '999'
group by b.branch_desc,Gd.product_no_string,b.branch_code,s.sizes_desc,c.colour_desc
Union
/*--------QC QTY-------*/
select B.BRANCH_DESC,
pm.prod_code,
sum(ph.stock_units_Qc) as QC_stock,
'BLANK',
'BLANK',
'BLANK',
'BLANK'
from product_master pm,product_history ph,BRANCH B
where PH.week_selector = @week
AND B.BRANCH_ID = PH.BRANCH_ID
and pm.prod_id = ph.product_id
and ph.stock_units_QC <>0
group by pm.prod_code,B.BRANCH_DESC
end
|