Subject Re: [IBO] IB_WISQL problem (maybe) - the code
Author Paul Little
Ok, so this list (or is it Yahoogroups) trims off attachments....

This was lifted straight off the source pane of the procedures tab in
the WISQL browser.



declare variable curpnum integer;
declare variable maxpnum integer;
begin
select max(prd) from incomestatement into :maxpnum;
curpnum = 0;
while (curpnum <= maxpnum) do
begin
insert into fifthpercentile(PERIOD)
values (:curpnum);

update fifthpercentile set REVENUES = (select sum(REVENUES) from
incomestatement
where incomestatement.prd =
:curpnum)*0.05
where period = :curpnum;

update fifthpercentile set COSTS = (select sum(COSTS) from
incomestatement
where incomestatement.prd =
:curpnum)*0.05
where period = :curpnum;

update fifthpercentile set EBITDA = (select sum(EBITDA) from
incomestatement
where incomestatement.prd =
:curpnum)*0.05
where period = :curpnum;

update fifthpercentile set DEPRECIATION = (select sum(DEPRECIATION)
from incomestatement
where
incomestatement.prd = :curpnum)*0.05
where period = :curpnum;

update fifthpercentile set EBIT = (select sum(EBIT) from
incomestatement
where incomestatement.prd =
:curpnum)*0.05
where period = :curpnum;

update fifthpercentile set NETINTERESTCOST = (select
sum(NETINTERESTCOST) from incomestatement
where
incomestatement.prd = :curpnum)*0.05
where period = :curpnum;

update fifthpercentile set EBT = (select sum(EBT) from
incomestatement
where incomestatement.prd =
:curpnum)*0.05
where period = :curpnum;

update fifthpercentile set TAXES = (select sum(TAXES) from
incomestatement
where incomestatement.prd =
:curpnum)*0.05
where period = :curpnum;

update fifthpercentile set NETINCOME = (select sum(NETINCOME) from
incomestatement
where incomestatement.prd =
:curpnum)*0.05
where period = :curpnum;

update fifthpercentile set DIVIDENDS = (select sum(DIVIDENDS) from
incomestatement
where incomestatement.prd =
:curpnum)*0.05
where period = :curpnum;

update fifthpercentile set RETAINEDEARNINGS = (select
sum(RETAINEDEARNINGS) from incomestatement
where
incomestatement.prd = :curpnum)*0.05
where period = :curpnum;

update fifthpercentile set CAPITALEXPENDITURE = (select
sum(CAPITALEXPENDITURE) from incomestatement
where
incomestatement.prd = :curpnum)*0.05
where period = :curpnum;

update fifthpercentile set CASH = (select sum(CASH) from
balancesheet
where balancesheet.prd =
:curpnum)*0.05
where period = :curpnum;

update fifthpercentile set RECVBLSOTHERCRNTASTS = (select
sum(RECVBLSOTHERCRNTASTS) from balancesheet
where
balancesheet.prd = :curpnum)*0.05
where period = :curpnum;

update fifthpercentile set CURRENTASSETS = (select
sum(CURRENTASSETS) from balancesheet
where balancesheet.prd =
:curpnum)*0.05
where period = :curpnum;

update fifthpercentile set FIXEDASSETS = (select sum(FIXEDASSETS)
from balancesheet
where balancesheet.prd
= :curpnum)*0.05
where period = :curpnum;

update fifthpercentile set TOTALASSETS = (select sum(TOTALASSETS)
from balancesheet
where balancesheet.prd =
:curpnum)*0.05
where period = :curpnum;

update fifthpercentile set SHORTTERMDEBT = (select
sum(SHORTTERMDEBT) from balancesheet
where balancesheet.prd =
:curpnum)*0.05
where period = :curpnum;

update fifthpercentile set OTHERCURRENTLIABS = (select
sum(OTHERCURRENTLIABS) from balancesheet
where
balancesheet.prd = :curpnum)*0.05
where period = :curpnum;

update fifthpercentile set CURRENTLIABILITIES = (select
sum(CURRENTLIABILITIES) from balancesheet
where
balancesheet.prd = :curpnum)*0.05
where period = :curpnum;

update fifthpercentile set LONGTERMDEBT = (select sum(LONGTERMDEBT)
from balancesheet
where balancesheet.prd =
:curpnum)*0.05
where period = :curpnum;

update fifthpercentile set OTHERLONGTERMLIABS = (select
sum(OTHERLONGTERMLIABS) from balancesheet
where
balancesheet.prd = :curpnum)*0.05
where period = :curpnum;

update fifthpercentile set LONGTERMLIABILITIES = (select
sum(LONGTERMLIABILITIES) from balancesheet
where
balancesheet.prd = :curpnum)*0.05
where period = :curpnum;

update fifthpercentile set TOTALLIABILITIES = (select
sum(TOTALLIABILITIES) from balancesheet
where
balancesheet.prd = :curpnum)*0.05
where period = :curpnum;

update fifthpercentile set SHARECAPITAL = (select sum(SHARECAPITAL)
from balancesheet
where balancesheet.prd =
:curpnum)*0.05
where period = :curpnum;

update fifthpercentile set RESERVES = (select sum(RESERVES) from
balancesheet
where balancesheet.prd =
:curpnum)*0.05
where period = :curpnum;

update fifthpercentile set SHAREHOLDERSEQUITY = (select
sum(SHAREHOLDERSEQUITY) from balancesheet
where
balancesheet.prd = :curpnum)*0.05
where period = :curpnum;

update fifthpercentile set TOTSHRHLDSEQTYLIABS = (select
sum(TOTSHRHLDSEQTYLIABS) from balancesheet
where
balancesheet.prd = :curpnum)*0.05
where period = :curpnum;

update fifthpercentile set ROEBOOK = (select sum(ROEBOOK) from
accountingratios
where accountingratios.prd =
:curpnum)*0.05
where period = :curpnum;

update fifthpercentile set ROEMARKET = (select sum(ROEMARKET) from
accountingratios
where accountingratios.prd =
:curpnum)*0.05
where period = :curpnum;

update fifthpercentile set RONA = (select sum(RONA) from
accountingratios
where accountingratios.prd =
:curpnum)*0.05
where period = :curpnum;

update fifthpercentile set PROFITMARGIN = (select sum(PROFITMARGIN)
from accountingratios
where
accountingratios.prd = :curpnum)*0.05
where period = :curpnum;

update fifthpercentile set NETASSETTURNOVER = (select
sum(NETASSETTURNOVER) from accountingratios
where
accountingratios.prd = :curpnum)*0.05
where period = :curpnum;

update fifthpercentile set DEBTCAPITALEMPLOYED = (select
sum(DEBTCAPITALEMPLOYED) from accountingratios
where
accountingratios.prd = :curpnum)*0.05
where period = :curpnum;

update fifthpercentile set INTERESTCOVERTIMES = (select
sum(INTERESTCOVERTIMES) from accountingratios
where
accountingratios.prd = :curpnum)*0.05
where period = :curpnum;

update fifthpercentile set EBITDAINTRSTCVRTIMES = (select
sum(EBITDAINTRSTCVRTIMES) from accountingratios
where
accountingratios.prd = :curpnum)*0.05
where period = :curpnum;

update fifthpercentile set EPS = (select sum(EPS) from
accountingratios
where accountingratios.prd =
:curpnum)*0.05
where period = :curpnum;

update fifthpercentile set PERATIO = (select sum(PERATIO) from
accountingratios
where accountingratios.prd =
:curpnum)*0.05
where period = :curpnum;

update fifthpercentile set DIVIDENDYIELD = (select
sum(DIVIDENDYIELD) from accountingratios
where
accountingratios.prd = :curpnum)*0.05
where period = :curpnum;

update fifthpercentile set DIVIDENDCOVERTIMES = (select
sum(DIVIDENDCOVERTIMES) from accountingratios
where
accountingratios.prd = :curpnum)*0.05
where period = :curpnum;

update fifthpercentile set ROCE = (select sum(ROCE) from
accountingratios
where accountingratios.prd =
:curpnum)*0.05
where period = :curpnum;

update fifthpercentile set ROIC = (select sum(ROIC) from
accountingratios
where accountingratios.prd =
:curpnum)*0.05
where period = :curpnum;

update fifthpercentile set WACC = (select sum(WACC) from
accountingratios
where accountingratios.prd =
:curpnum)*0.05
where period = :curpnum;

update fifthpercentile set CAPITALCHARGE = (select
sum(CAPITALCHARGE) from accountingratios
where
accountingratios.prd = :curpnum)*0.05
where period = :curpnum;

update fifthpercentile set EVASPREAD = (select sum(EVASPREAD) from
accountingratios
where accountingratios.prd =
:curpnum)*0.05
where period = :curpnum;

update fifthpercentile set EVA = (select sum(EVA) from
accountingratios
where accountingratios.prd =
:curpnum)*0.05
where period = :curpnum;


insert into twentyfifthpercentile(PERIOD)
values (:curpnum);

update twentyfifthpercentile set REVENUES = (select sum(REVENUES)
from incomestatement
where incomestatement.prd =
:curpnum)*0.25
where period = :curpnum;

update twentyfifthpercentile set COSTS = (select sum(COSTS) from
incomestatement
where incomestatement.prd =
:curpnum)*0.25
where period = :curpnum;

update twentyfifthpercentile set EBITDA = (select sum(EBITDA) from
incomestatement
where incomestatement.prd =
:curpnum)*0.25
where period = :curpnum;

update twentyfifthpercentile set DEPRECIATION = (select
sum(DEPRECIATION) from incomestatement
where
incomestatement.prd = :curpnum)*0.25
where period = :curpnum;

update twentyfifthpercentile set EBIT = (select sum(EBIT) from
incomestatement
where incomestatement.prd =
:curpnum)*0.25
where period = :curpnum;

update twentyfifthpercentile set NETINTERESTCOST = (select
sum(NETINTERESTCOST) from incomestatement
where
incomestatement.prd = :curpnum)*0.25
where period = :curpnum;

update twentyfifthpercentile set EBT = (select sum(EBT) from
incomestatement
where incomestatement.prd =
:curpnum)*0.25
where period = :curpnum;

update twentyfifthpercentile set TAXES = (select sum(TAXES) from
incomestatement
where incomestatement.prd =
:curpnum)*0.25
where period = :curpnum;

update twentyfifthpercentile set NETINCOME = (select sum(NETINCOME)
from incomestatement
where incomestatement.prd =
:curpnum)*0.25
where period = :curpnum;

update twentyfifthpercentile set DIVIDENDS = (select sum(DIVIDENDS)
from incomestatement
where incomestatement.prd =
:curpnum)*0.25
where period = :curpnum;

update twentyfifthpercentile set RETAINEDEARNINGS = (select
sum(RETAINEDEARNINGS) from incomestatement
where
incomestatement.prd = :curpnum)*0.25
where period = :curpnum;

update twentyfifthpercentile set CAPITALEXPENDITURE = (select
sum(CAPITALEXPENDITURE) from incomestatement
where
incomestatement.prd = :curpnum)*0.25
where period = :curpnum;

update twentyfifthpercentile set CASH = (select sum(CASH) from
balancesheet
where balancesheet.prd =
:curpnum)*0.25
where period = :curpnum;

update twentyfifthpercentile set RECVBLSOTHERCRNTASTS = (select
sum(RECVBLSOTHERCRNTASTS) from balancesheet
where
balancesheet.prd = :curpnum)*0.25
where period = :curpnum;

update twentyfifthpercentile set CURRENTASSETS = (select
sum(CURRENTASSETS) from balancesheet
where balancesheet.prd =
:curpnum)*0.25
where period = :curpnum;

update twentyfifthpercentile set FIXEDASSETS = (select
sum(FIXEDASSETS) from balancesheet
where balancesheet.prd
= :curpnum)*0.25
where period = :curpnum;

update twentyfifthpercentile set TOTALASSETS = (select
sum(TOTALASSETS) from balancesheet
where balancesheet.prd =
:curpnum)*0.25
where period = :curpnum;

update twentyfifthpercentile set SHORTTERMDEBT = (select
sum(SHORTTERMDEBT) from balancesheet
where balancesheet.prd =
:curpnum)*0.25
where period = :curpnum;

update twentyfifthpercentile set OTHERCURRENTLIABS = (select
sum(OTHERCURRENTLIABS) from balancesheet
where
balancesheet.prd = :curpnum)*0.25
where period = :curpnum;

update twentyfifthpercentile set CURRENTLIABILITIES = (select
sum(CURRENTLIABILITIES) from balancesheet
where
balancesheet.prd = :curpnum)*0.25
where period = :curpnum;

update twentyfifthpercentile set LONGTERMDEBT = (select
sum(LONGTERMDEBT) from balancesheet
where balancesheet.prd =
:curpnum)*0.25
where period = :curpnum;

update twentyfifthpercentile set OTHERLONGTERMLIABS = (select
sum(OTHERLONGTERMLIABS) from balancesheet
where
balancesheet.prd = :curpnum)*0.25
where period = :curpnum;

update twentyfifthpercentile set LONGTERMLIABILITIES = (select
sum(LONGTERMLIABILITIES) from balancesheet
where
balancesheet.prd = :curpnum)*0.25
where period = :curpnum;

update twentyfifthpercentile set TOTALLIABILITIES = (select
sum(TOTALLIABILITIES) from balancesheet
where
balancesheet.prd = :curpnum)*0.25
where period = :curpnum;

update twentyfifthpercentile set SHARECAPITAL = (select
sum(SHARECAPITAL) from balancesheet
where balancesheet.prd =
:curpnum)*0.25
where period = :curpnum;

update twentyfifthpercentile set RESERVES = (select sum(RESERVES)
from balancesheet
where balancesheet.prd =
:curpnum)*0.25
where period = :curpnum;

update twentyfifthpercentile set SHAREHOLDERSEQUITY = (select
sum(SHAREHOLDERSEQUITY) from balancesheet
where
balancesheet.prd = :curpnum)*0.25
where period = :curpnum;

update twentyfifthpercentile set TOTSHRHLDSEQTYLIABS = (select
sum(TOTSHRHLDSEQTYLIABS) from balancesheet
where
balancesheet.prd = :curpnum)*0.25
where period = :curpnum;

update twentyfifthpercentile set ROEBOOK = (select sum(ROEBOOK) from
accountingratios
where accountingratios.prd =
:curpnum)*0.25
where period = :curpnum;

update twentyfifthpercentile set ROEMARKET = (select sum(ROEMARKET)
from accountingratios
where accountingratios.prd =
:curpnum)*0.25
where period = :curpnum;

update twentyfifthpercentile set RONA = (select sum(RONA) from
accountingratios
where accountingratios.prd =
:curpnum)*0.25
where period = :curpnum;

update twentyfifthpercentile set PROFITMARGIN = (select
sum(PROFITMARGIN) from accountingratios
where
accountingratios.prd = :curpnum)*0.25
where period = :curpnum;

update twentyfifthpercentile set NETASSETTURNOVER = (select
sum(NETASSETTURNOVER) from accountingratios
where
accountingratios.prd = :curpnum)*0.25
where period = :curpnum;

update twentyfifthpercentile set DEBTCAPITALEMPLOYED = (select
sum(DEBTCAPITALEMPLOYED) from accountingratios
where
accountingratios.prd = :curpnum)*0.25
where period = :curpnum;

update twentyfifthpercentile set INTERESTCOVERTIMES = (select
sum(INTERESTCOVERTIMES) from accountingratios
where
accountingratios.prd = :curpnum)*0.25
where period = :curpnum;

update twentyfifthpercentile set EBITDAINTRSTCVRTIMES = (select
sum(EBITDAINTRSTCVRTIMES) from accountingratios
where
accountingratios.prd = :curpnum)*0.25
where period = :curpnum;

update twentyfifthpercentile set EPS = (select sum(EPS) from
accountingratios
where accountingratios.prd =
:curpnum)*0.25
where period = :curpnum;

update twentyfifthpercentile set PERATIO = (select sum(PERATIO) from
accountingratios
where accountingratios.prd =
:curpnum)*0.25
where period = :curpnum;

update twentyfifthpercentile set DIVIDENDYIELD = (select
sum(DIVIDENDYIELD) from accountingratios
where
accountingratios.prd = :curpnum)*0.25
where period = :curpnum;

update twentyfifthpercentile set DIVIDENDCOVERTIMES = (select
sum(DIVIDENDCOVERTIMES) from accountingratios
where
accountingratios.prd = :curpnum)*0.25
where period = :curpnum;

update twentyfifthpercentile set ROCE = (select sum(ROCE) from
accountingratios
where accountingratios.prd =
:curpnum)*0.25
where period = :curpnum;

update twentyfifthpercentile set ROIC = (select sum(ROIC) from
accountingratios
where accountingratios.prd =
:curpnum)*0.25
where period = :curpnum;

update twentyfifthpercentile set WACC = (select sum(WACC) from
accountingratios
where accountingratios.prd =
:curpnum)*0.25
where period = :curpnum;

update twentyfifthpercentile set CAPITALCHARGE = (select
sum(CAPITALCHARGE) from accountingratios
where
accountingratios.prd = :curpnum)*0.25
where period = :curpnum;

update twentyfifthpercentile set EVASPREAD = (select sum(EVASPREAD)
from accountingratios
where accountingratios.prd =
:curpnum)*0.25
where period = :curpnum;

update twentyfifthpercentile set EVA = (select sum(EVA) from
accountingratios
where accountingratios.prd =
:curpnum)*0.25
where period = :curpnum;


insert into seventyfifthpercentile(PERIOD)
values (:curpnum);

update seventyfifthpercentile set REVENUES = (select sum(REVENUES)
from incomestatement
where incomestatement.prd =
:curpnum)*0.75
where period = :curpnum;

update seventyfifthpercentile set COSTS = (select sum(COSTS) from
incomestatement
where incomestatement.prd =
:curpnum)*0.75
where period = :curpnum;

update seventyfifthpercentile set EBITDA = (select sum(EBITDA) from
incomestatement
where incomestatement.prd =
:curpnum)*0.75
where period = :curpnum;

update seventyfifthpercentile set DEPRECIATION = (select
sum(DEPRECIATION) from incomestatement
where
incomestatement.prd = :curpnum)*0.75
where period = :curpnum;

update seventyfifthpercentile set EBIT = (select sum(EBIT) from
incomestatement
where incomestatement.prd =
:curpnum)*0.75
where period = :curpnum;

update seventyfifthpercentile set NETINTERESTCOST = (select
sum(NETINTERESTCOST) from incomestatement
where
incomestatement.prd = :curpnum)*0.75
where period = :curpnum;

update seventyfifthpercentile set EBT = (select sum(EBT) from
incomestatement
where incomestatement.prd =
:curpnum)*0.75
where period = :curpnum;

update seventyfifthpercentile set TAXES = (select sum(TAXES) from
incomestatement
where incomestatement.prd =
:curpnum)*0.75
where period = :curpnum;

update seventyfifthpercentile set NETINCOME = (select sum(NETINCOME)
from incomestatement
where incomestatement.prd =
:curpnum)*0.75
where period = :curpnum;

update seventyfifthpercentile set DIVIDENDS = (select sum(DIVIDENDS)
from incomestatement
where incomestatement.prd =
:curpnum)*0.75
where period = :curpnum;

update seventyfifthpercentile set RETAINEDEARNINGS = (select
sum(RETAINEDEARNINGS) from incomestatement
where
incomestatement.prd = :curpnum)*0.75
where period = :curpnum;

update seventyfifthpercentile set CAPITALEXPENDITURE = (select
sum(CAPITALEXPENDITURE) from incomestatement
where
incomestatement.prd = :curpnum)*0.75
where period = :curpnum;

update seventyfifthpercentile set CASH = (select sum(CASH) from
balancesheet
where balancesheet.prd =
:curpnum)*0.75
where period = :curpnum;

update seventyfifthpercentile set RECVBLSOTHERCRNTASTS = (select
sum(RECVBLSOTHERCRNTASTS) from balancesheet
where
balancesheet.prd = :curpnum)*0.75
where period = :curpnum;

update seventyfifthpercentile set CURRENTASSETS = (select
sum(CURRENTASSETS) from balancesheet
where balancesheet.prd =
:curpnum)*0.75
where period = :curpnum;

update seventyfifthpercentile set FIXEDASSETS = (select
sum(FIXEDASSETS) from balancesheet
where balancesheet.prd
= :curpnum)*0.75
where period = :curpnum;

update seventyfifthpercentile set TOTALASSETS = (select
sum(TOTALASSETS) from balancesheet
where balancesheet.prd =
:curpnum)*0.75
where period = :curpnum;

update seventyfifthpercentile set SHORTTERMDEBT = (select
sum(SHORTTERMDEBT) from balancesheet
where balancesheet.prd =
:curpnum)*0.75
where period = :curpnum;

update seventyfifthpercentile set OTHERCURRENTLIABS = (select
sum(OTHERCURRENTLIABS) from balancesheet
where
balancesheet.prd = :curpnum)*0.75
where period = :curpnum;

update seventyfifthpercentile set CURRENTLIABILITIES = (select
sum(CURRENTLIABILITIES) from balancesheet
where
balancesheet.prd = :curpnum)*0.75
where period = :curpnum;

update seventyfifthpercentile set LONGTERMDEBT = (select
sum(LONGTERMDEBT) from balancesheet
where balancesheet.prd =
:curpnum)*0.75
where period = :curpnum;

update seventyfifthpercentile set OTHERLONGTERMLIABS = (select
sum(OTHERLONGTERMLIABS) from balancesheet
where
balancesheet.prd = :curpnum)*0.75
where period = :curpnum;

update seventyfifthpercentile set LONGTERMLIABILITIES = (select
sum(LONGTERMLIABILITIES) from balancesheet
where
balancesheet.prd = :curpnum)*0.75
where period = :curpnum;

update seventyfifthpercentile set TOTALLIABILITIES = (select
sum(TOTALLIABILITIES) from balancesheet
where
balancesheet.prd = :curpnum)*0.75
where period = :curpnum;

update seventyfifthpercentile set SHARECAPITAL = (select
sum(SHARECAPITAL) from balancesheet
where balancesheet.prd =
:curpnum)*0.75
where period = :curpnum;

update seventyfifthpercentile set RESERVES = (select sum(RESERVES)
from balancesheet
where balancesheet.prd =
:curpnum)*0.75
where period = :curpnum;

update seventyfifthpercentile set SHAREHOLDERSEQUITY = (select
sum(SHAREHOLDERSEQUITY) from balancesheet
where
balancesheet.prd = :curpnum)*0.75
where period = :curpnum;

update seventyfifthpercentile set TOTSHRHLDSEQTYLIABS = (select
sum(TOTSHRHLDSEQTYLIABS) from balancesheet
where
balancesheet.prd = :curpnum)*0.75
where period = :curpnum;

update seventyfifthpercentile set ROEBOOK = (select sum(ROEBOOK)
from accountingratios
where accountingratios.prd =
:curpnum)*0.75
where period = :curpnum;

update seventyfifthpercentile set ROEMARKET = (select sum(ROEMARKET)
from accountingratios
where accountingratios.prd =
:curpnum)*0.75
where period = :curpnum;

update seventyfifthpercentile set RONA = (select sum(RONA) from
accountingratios
where accountingratios.prd =
:curpnum)*0.75
where period = :curpnum;

update seventyfifthpercentile set PROFITMARGIN = (select
sum(PROFITMARGIN) from accountingratios
where
accountingratios.prd = :curpnum)*0.75
where period = :curpnum;

update seventyfifthpercentile set NETASSETTURNOVER = (select
sum(NETASSETTURNOVER) from accountingratios
where
accountingratios.prd = :curpnum)*0.75
where period = :curpnum;

update seventyfifthpercentile set DEBTCAPITALEMPLOYED = (select
sum(DEBTCAPITALEMPLOYED) from accountingratios
where
accountingratios.prd = :curpnum)*0.75
where period = :curpnum;

update seventyfifthpercentile set INTERESTCOVERTIMES = (select
sum(INTERESTCOVERTIMES) from accountingratios
where
accountingratios.prd = :curpnum)*0.75
where period = :curpnum;

update seventyfifthpercentile set EBITDAINTRSTCVRTIMES = (select
sum(EBITDAINTRSTCVRTIMES) from accountingratios
where
accountingratios.prd = :curpnum)*0.75
where period = :curpnum;

update seventyfifthpercentile set EPS = (select sum(EPS) from
accountingratios
where accountingratios.prd =
:curpnum)*0.75
where period = :curpnum;

update seventyfifthpercentile set PERATIO = (select sum(PERATIO)
from accountingratios
where accountingratios.prd =
:curpnum)*0.75
where period = :curpnum;

update seventyfifthpercentile set DIVIDENDYIELD = (select
sum(DIVIDENDYIELD) from accountingratios
where
accountingratios.prd = :curpnum)*0.75
where period = :curpnum;

update seventyfifthpercentile set DIVIDENDCOVERTIMES = (select
sum(DIVIDENDCOVERTIMES) from accountingratios
where
accountingratios.prd = :curpnum)*0.75
where period = :curpnum;

update seventyfifthpercentile set ROCE = (select sum(ROCE) from
accountingratios
where accountingratios.prd =
:curpnum)*0.75
where period = :curpnum;

update seventyfifthpercentile set ROIC = (select sum(ROIC) from
accountingratios
where accountingratios.prd =
:curpnum)*0.75
where period = :curpnum;

update seventyfifthpercentile set WACC = (select sum(WACC) from
accountingratios
where accountingratios.prd =
:curpnum)*0.75
where period = :curpnum;

update seventyfifthpercentile set CAPITALCHARGE = (select
sum(CAPITALCHARGE) from accountingratios
where
accountingratios.prd = :curpnum)*0.75
where period = :curpnum;

update seventyfifthpercentile set EVASPREAD = (select sum(EVASPREAD)
from accountingratios
where accountingratios.prd =
:curpnum)*0.75
where period = :curpnum;

update seventyfifthpercentile set EVA = (select sum(EVA) from
accountingratios
where accountingratios.prd =
:curpnum)*0.75
where period = :curpnum;


insert into ninetyfifthpercentile(PERIOD)
values (:curpnum);

update ninetyfifthpercentile set REVENUES = (select sum(REVENUES)
from incomestatement
where incomestatement.prd =
:curpnum)*0.95
where period = :curpnum;

update ninetyfifthpercentile set COSTS = (select sum(COSTS) from
incomestatement
where incomestatement.prd =
:curpnum)*0.95
where period = :curpnum;

update ninetyfifthpercentile set EBITDA = (select sum(EBITDA) from
incomestatement
where incomestatement.prd =
:curpnum)*0.95
where period = :curpnum;

update ninetyfifthpercentile set DEPRECIATION = (select
sum(DEPRECIATION) from incomestatement
where
incomestatement.prd = :curpnum)*0.95
where period = :curpnum;

update ninetyfifthpercentile set EBIT = (select sum(EBIT) from
incomestatement
where incomestatement.prd =
:curpnum)*0.95
where period = :curpnum;

update ninetyfifthpercentile set NETINTERESTCOST = (select
sum(NETINTERESTCOST) from incomestatement
where
incomestatement.prd = :curpnum)*0.95
where period = :curpnum;

update ninetyfifthpercentile set EBT = (select sum(EBT) from
incomestatement
where incomestatement.prd =
:curpnum)*0.95
where period = :curpnum;

update ninetyfifthpercentile set TAXES = (select sum(TAXES) from
incomestatement
where incomestatement.prd =
:curpnum)*0.95
where period = :curpnum;

update ninetyfifthpercentile set NETINCOME = (select sum(NETINCOME)
from incomestatement
where incomestatement.prd =
:curpnum)*0.95
where period = :curpnum;

update ninetyfifthpercentile set DIVIDENDS = (select sum(DIVIDENDS)
from incomestatement
where incomestatement.prd =
:curpnum)*0.95
where period = :curpnum;

update ninetyfifthpercentile set RETAINEDEARNINGS = (select
sum(RETAINEDEARNINGS) from incomestatement
where
incomestatement.prd = :curpnum)*0.95
where period = :curpnum;

update ninetyfifthpercentile set CAPITALEXPENDITURE = (select
sum(CAPITALEXPENDITURE) from incomestatement
where
incomestatement.prd = :curpnum)*0.95
where period = :curpnum;

update ninetyfifthpercentile set CASH = (select sum(CASH) from
balancesheet
where balancesheet.prd =
:curpnum)*0.95
where period = :curpnum;

update ninetyfifthpercentile set RECVBLSOTHERCRNTASTS = (select
sum(RECVBLSOTHERCRNTASTS) from balancesheet
where
balancesheet.prd = :curpnum)*0.95
where period = :curpnum;

update ninetyfifthpercentile set CURRENTASSETS = (select
sum(CURRENTASSETS) from balancesheet
where balancesheet.prd =
:curpnum)*0.95
where period = :curpnum;

update ninetyfifthpercentile set FIXEDASSETS = (select
sum(FIXEDASSETS) from balancesheet
where balancesheet.prd
= :curpnum)*0.95
where period = :curpnum;

update ninetyfifthpercentile set TOTALASSETS = (select
sum(TOTALASSETS) from balancesheet
where balancesheet.prd =
:curpnum)*0.95
where period = :curpnum;

update ninetyfifthpercentile set SHORTTERMDEBT = (select
sum(SHORTTERMDEBT) from balancesheet
where balancesheet.prd =
:curpnum)*0.95
where period = :curpnum;

update ninetyfifthpercentile set OTHERCURRENTLIABS = (select
sum(OTHERCURRENTLIABS) from balancesheet
where
balancesheet.prd = :curpnum)*0.95
where period = :curpnum;

update ninetyfifthpercentile set CURRENTLIABILITIES = (select
sum(CURRENTLIABILITIES) from balancesheet
where
balancesheet.prd = :curpnum)*0.95
where period = :curpnum;

update ninetyfifthpercentile set LONGTERMDEBT = (select
sum(LONGTERMDEBT) from balancesheet
where balancesheet.prd =
:curpnum)*0.95
where period = :curpnum;

update ninetyfifthpercentile set OTHERLONGTERMLIABS = (select
sum(OTHERLONGTERMLIABS) from balancesheet
where
balancesheet.prd = :curpnum)*0.95
where period = :curpnum;

update ninetyfifthpercentile set LONGTERMLIABILITIES = (select
sum(LONGTERMLIABILITIES) from balancesheet
where
balancesheet.prd = :curpnum)*0.95
where period = :curpnum;

update ninetyfifthpercentile set TOTALLIABILITIES = (select
sum(TOTALLIABILITIES) from balancesheet
where
balancesheet.prd = :curpnum)*0.95
where period = :curpnum;

update ninetyfifthpercentile set SHARECAPITAL = (select
sum(SHARECAPITAL) from balancesheet
where balancesheet.prd =
:curpnum)*0.95
where period = :curpnum;

update ninetyfifthpercentile set RESERVES = (select sum(RESERVES)
from balancesheet
where balancesheet.prd =
:curpnum)*0.95
where period = :curpnum;

update ninetyfifthpercentile set SHAREHOLDERSEQUITY = (select
sum(SHAREHOLDERSEQUITY) from balancesheet
where
balancesheet.prd = :curpnum)*0.95
where period = :curpnum;

update ninetyfifthpercentile set TOTSHRHLDSEQTYLIABS = (select
sum(TOTSHRHLDSEQTYLIABS) from balancesheet
where
balancesheet.prd = :curpnum)*0.95
where period = :curpnum;

update ninetyfifthpercentile set ROEBOOK = (select sum(ROEBOOK) from
accountingratios
where accountingratios.prd =
:curpnum)*0.95
where period = :curpnum;

update ninetyfifthpercentile set ROEMARKET = (select sum(ROEMARKET)
from accountingratios
where accountingratios.prd =
:curpnum)*0.95
where period = :curpnum;

update ninetyfifthpercentile set RONA = (select sum(RONA) from
accountingratios
where accountingratios.prd =
:curpnum)*0.95
where period = :curpnum;

update ninetyfifthpercentile set PROFITMARGIN = (select
sum(PROFITMARGIN) from accountingratios
where
accountingratios.prd = :curpnum)*0.95
where period = :curpnum;

update ninetyfifthpercentile set NETASSETTURNOVER = (select
sum(NETASSETTURNOVER) from accountingratios
where
accountingratios.prd = :curpnum)*0.95
where period = :curpnum;

update ninetyfifthpercentile set DEBTCAPITALEMPLOYED = (select
sum(DEBTCAPITALEMPLOYED) from accountingratios
where
accountingratios.prd = :curpnum)*0.95
where period = :curpnum;

update ninetyfifthpercentile set INTERESTCOVERTIMES = (select
sum(INTERESTCOVERTIMES) from accountingratios
where
accountingratios.prd = :curpnum)*0.95
where period = :curpnum;

update ninetyfifthpercentile set EBITDAINTRSTCVRTIMES = (select
sum(EBITDAINTRSTCVRTIMES) from accountingratios
where
accountingratios.prd = :curpnum)*0.95
where period = :curpnum;

update ninetyfifthpercentile set EPS = (select sum(EPS) from
accountingratios
where accountingratios.prd =
:curpnum)*0.95
where period = :curpnum;

update ninetyfifthpercentile set PERATIO = (select sum(PERATIO) from
accountingratios
where accountingratios.prd =
:curpnum)*0.95
where period = :curpnum;

update ninetyfifthpercentile set DIVIDENDYIELD = (select
sum(DIVIDENDYIELD) from accountingratios
where
accountingratios.prd = :curpnum)*0.95
where period = :curpnum;

update ninetyfifthpercentile set DIVIDENDCOVERTIMES = (select
sum(DIVIDENDCOVERTIMES) from accountingratios
where
accountingratios.prd = :curpnum)*0.95
where period = :curpnum;

update ninetyfifthpercentile set ROCE = (select sum(ROCE) from
accountingratios
where accountingratios.prd =
:curpnum)*0.95
where period = :curpnum;

update ninetyfifthpercentile set ROIC = (select sum(ROIC) from
accountingratios
where accountingratios.prd =
:curpnum)*0.95
where period = :curpnum;

update ninetyfifthpercentile set WACC = (select sum(WACC) from
accountingratios
where accountingratios.prd =
:curpnum)*0.95
where period = :curpnum;

update ninetyfifthpercentile set CAPITALCHARGE = (select
sum(CAPITALCHARGE) from accountingratios
where
accountingratios.prd = :curpnum)*0.95
where period = :curpnum;

update ninetyfifthpercentile set EVASPREAD = (select sum(EVASPREAD)
from accountingratios
where accountingratios.prd =
:curpnum)*0.95
where period = :curpnum;

update ninetyfifthpercentile set EVA = (select sum(EVA) from
accountingratios
where accountingratios.prd =
:curpnum)*0.95
where period = :curpnum;


insert into meanpercentile(PERIOD)
values (:curpnum);

update meanpercentile set REVENUES = (select avg(REVENUES) from
incomestatement
where incomestatement.prd =
:curpnum)
where period = :curpnum;

update meanpercentile set COSTS = (select avg(COSTS) from
incomestatement
where incomestatement.prd =
:curpnum)
where period = :curpnum;

update meanpercentile set EBITDA = (select avg(EBITDA) from
incomestatement
where incomestatement.prd =
:curpnum)
where period = :curpnum;

update meanpercentile set DEPRECIATION = (select avg(DEPRECIATION)
from incomestatement
where
incomestatement.prd = :curpnum)
where period = :curpnum;

update meanpercentile set EBIT = (select avg(EBIT) from
incomestatement
where incomestatement.prd =
:curpnum)
where period = :curpnum;

update meanpercentile set NETINTERESTCOST = (select
avg(NETINTERESTCOST) from incomestatement
where
incomestatement.prd = :curpnum)
where period = :curpnum;

update meanpercentile set EBT = (select avg(EBT) from
incomestatement
where incomestatement.prd =
:curpnum)
where period = :curpnum;

update meanpercentile set TAXES = (select avg(TAXES) from
incomestatement
where incomestatement.prd =
:curpnum)
where period = :curpnum;

update meanpercentile set NETINCOME = (select avg(NETINCOME) from
incomestatement
where incomestatement.prd =
:curpnum)
where period = :curpnum;

update meanpercentile set DIVIDENDS = (select avg(DIVIDENDS) from
incomestatement
where incomestatement.prd =
:curpnum)
where period = :curpnum;

update meanpercentile set RETAINEDEARNINGS = (select
avg(RETAINEDEARNINGS) from incomestatement
where
incomestatement.prd = :curpnum)
where period = :curpnum;

update meanpercentile set CAPITALEXPENDITURE = (select
avg(CAPITALEXPENDITURE) from incomestatement
where
incomestatement.prd = :curpnum)
where period = :curpnum;

update meanpercentile set CASH = (select avg(CASH) from balancesheet
where balancesheet.prd =
:curpnum)
where period = :curpnum;

update meanpercentile set RECVBLSOTHERCRNTASTS = (select
avg(RECVBLSOTHERCRNTASTS) from balancesheet
where
balancesheet.prd = :curpnum)
where period = :curpnum;

update meanpercentile set CURRENTASSETS = (select avg(CURRENTASSETS)
from balancesheet
where balancesheet.prd =
:curpnum)
where period = :curpnum;

update meanpercentile set FIXEDASSETS = (select avg(FIXEDASSETS)
from balancesheet
where balancesheet.prd
= :curpnum)
where period = :curpnum;

update meanpercentile set TOTALASSETS = (select avg(TOTALASSETS)
from balancesheet
where balancesheet.prd =
:curpnum)
where period = :curpnum;

update meanpercentile set SHORTTERMDEBT = (select avg(SHORTTERMDEBT)
from balancesheet
where balancesheet.prd =
:curpnum)
where period = :curpnum;

update meanpercentile set OTHERCURRENTLIABS = (select
avg(OTHERCURRENTLIABS) from balancesheet
where
balancesheet.prd = :curpnum)
where period = :curpnum;

update meanpercentile set CURRENTLIABILITIES = (select
avg(CURRENTLIABILITIES) from balancesheet
where
balancesheet.prd = :curpnum)
where period = :curpnum;

update meanpercentile set LONGTERMDEBT = (select avg(LONGTERMDEBT)
from balancesheet
where balancesheet.prd =
:curpnum)
where period = :curpnum;

update meanpercentile set OTHERLONGTERMLIABS = (select
avg(OTHERLONGTERMLIABS) from balancesheet
where
balancesheet.prd = :curpnum)
where period = :curpnum;

update meanpercentile set LONGTERMLIABILITIES = (select
avg(LONGTERMLIABILITIES) from balancesheet
where
balancesheet.prd = :curpnum)
where period = :curpnum;

update meanpercentile set TOTALLIABILITIES = (select
avg(TOTALLIABILITIES) from balancesheet
where
balancesheet.prd = :curpnum)
where period = :curpnum;

update meanpercentile set SHARECAPITAL = (select avg(SHARECAPITAL)
from balancesheet
where balancesheet.prd =
:curpnum)
where period = :curpnum;

update meanpercentile set RESERVES = (select avg(RESERVES) from
balancesheet
where balancesheet.prd =
:curpnum)
where period = :curpnum;

update meanpercentile set SHAREHOLDERSEQUITY = (select
avg(SHAREHOLDERSEQUITY) from balancesheet
where
balancesheet.prd = :curpnum)
where period = :curpnum;

update meanpercentile set TOTSHRHLDSEQTYLIABS = (select
avg(TOTSHRHLDSEQTYLIABS) from balancesheet
where
balancesheet.prd = :curpnum)
where period = :curpnum;

update meanpercentile set ROEBOOK = (select avg(ROEBOOK) from
accountingratios
where accountingratios.prd =
:curpnum)
where period = :curpnum;

update meanpercentile set ROEMARKET = (select avg(ROEMARKET) from
accountingratios
where accountingratios.prd =
:curpnum)
where period = :curpnum;

update meanpercentile set RONA = (select avg(RONA) from
accountingratios
where accountingratios.prd =
:curpnum)
where period = :curpnum;

update meanpercentile set PROFITMARGIN = (select avg(PROFITMARGIN)
from accountingratios
where
accountingratios.prd = :curpnum)
where period = :curpnum;

update meanpercentile set NETASSETTURNOVER = (select
avg(NETASSETTURNOVER) from accountingratios
where
accountingratios.prd = :curpnum)
where period = :curpnum;

update meanpercentile set DEBTCAPITALEMPLOYED = (select
avg(DEBTCAPITALEMPLOYED) from accountingratios
where
accountingratios.prd = :curpnum)
where period = :curpnum;

update meanpercentile set INTERESTCOVERTIMES = (select
avg(INTERESTCOVERTIMES) from accountingratios
where
accountingratios.prd = :curpnum)
where period = :curpnum;

update meanpercentile set EBITDAINTRSTCVRTIMES = (select
avg(EBITDAINTRSTCVRTIMES) from accountingratios
where
accountingratios.prd = :curpnum)
where period = :curpnum;

update meanpercentile set EPS = (select avg(EPS) from
accountingratios
where accountingratios.prd =
:curpnum)
where period = :curpnum;

update meanpercentile set PERATIO = (select avg(PERATIO) from
accountingratios
where accountingratios.prd =
:curpnum)
where period = :curpnum;

update meanpercentile set DIVIDENDYIELD = (select avg(DIVIDENDYIELD)
from accountingratios
where
accountingratios.prd = :curpnum)
where period = :curpnum;

update meanpercentile set DIVIDENDCOVERTIMES = (select
avg(DIVIDENDCOVERTIMES) from accountingratios
where
accountingratios.prd = :curpnum)
where period = :curpnum;

update meanpercentile set ROCE = (select avg(ROCE) from
accountingratios
where accountingratios.prd =
:curpnum)
where period = :curpnum;

update meanpercentile set ROIC = (select avg(ROIC) from
accountingratios
where accountingratios.prd =
:curpnum)
where period = :curpnum;

update meanpercentile set WACC = (select avg(WACC) from
accountingratios
where accountingratios.prd =
:curpnum)
where period = :curpnum;

update meanpercentile set CAPITALCHARGE = (select avg(CAPITALCHARGE)
from accountingratios
where
accountingratios.prd = :curpnum)
where period = :curpnum;

update meanpercentile set EVASPREAD = (select avg(EVASPREAD) from
accountingratios
where accountingratios.prd =
:curpnum)
where period = :curpnum;

update meanpercentile set EVA = (select avg(EVA) from
accountingratios
where accountingratios.prd =
:curpnum)
where period = :curpnum;





curpnum = curpnum + 1;
end
end