I have a complicated request. I have to make a report in PHP like the picture below.
Part summarized yield
must be filled with across calculation.
Like I explain in formula column, value in part summarized yield
got from calculation between location yield
and part summarized yield
.
(See this formula)
How to do that calculation in a PHP report? I already tried using a cursor, but it still did not work.
Here is my cursor calculation:
--In PHP file, i make query to insert data first to table tyield_summary
--Cursor to input yield_summary
Declare @nourut varchar(2), @maxnourut varchar(2), @bpnum varchar(20), @pnum varchar(20), @curnourut varchar(2), @psum decimal(18,2), @ysum decimal(18,2)
DECLARE StockCursor CURSOR
FOR
select no_urut, part_number, Part_Summary
from tyield_summary
where no_urut<>'99'
order by part_number desc, no_urut asc
set @bpnum=''
OPEN StockCursor
FETCH NEXT FROM StockCursor INTO @nourut, @pnum, @psum
WHILE @@FETCH_STATUS=0
BEGIN
if @bpnum=@pnum
begin
select top 1 @curnourut=no_urut
from tyield_summary
where part_number=@pnum
and no_urut<@nourut
order by no_urut desc
set @bpnum=@pnum
select @maxnourut = max(no_urut) from tyield_summary
where part_number=@pnum
update tyield_summary
set yield_summary = case when Part_Summary=0 then @psum else (Part_Summary*@psum)/100 end
where part_number=@pnum
and no_urut=@curnourut
end
else
begin
set @bpnum=@pnum
end
FETCH NEXT FROM StockCursor INTO @nourut, @pnum, @psum
END
CLOSE StockCursor
DEALLOCATE StockCursor
I need to fill part_summary
field using formula that i show in excel.
In formula show, calculation using cross field.