This stored procedure takes in an integer as an input parameter and outputs two tables. It selects the top input number of records from three tables joined together, sums the gross amount and groups by company name. The first output table orders the results by gross amount in ascending order, while the second output table orders the results by gross amount in descending order.
Download as DOCX, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
31 views
Begin Procedure Script
This stored procedure takes in an integer as an input parameter and outputs two tables. It selects the top input number of records from three tables joined together, sums the gross amount and groups by company name. The first output table orders the results by gross amount in ascending order, while the second output table orders the results by gross amount in descending order.
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1
create procedure "_SYS_BIC".
"student07/ZHA407_DP_TNF" ( in IV_NUMBER INTEGER
, out ET_FLOP "_SYS_BIC"."student07/ZHA407_DP_TNF/tabletype/ET_FLOP" , out ET_TOP "_SYS_BIC"."student07/ZHA407_DP_TNF/tabletype/ET_TOP" ) language SQLSCRIPT sql security definer reads sql data as /********* Begin Procedure Script ************/ BEGIN
et_flop = select top:iv_number/* use top clause to limit to iv_number records */ b.company_name as company_name, sum(i.gross_amount) as gross_amount from snwd_so_i as i inner join snwd_so as h on h.node_key = i.parent_key inner join snwd_bpa as b on b.node_key = h.buyer_guid group by company_name order by gross_amount asc;
et_top = select top:iv_number/* use top clause to limit to iv_number records */ b.company_name as company_name, sum(i.gross_amount) as gross_amount from snwd_so_i as i inner join snwd_so as h on h.node_key = i.parent_key inner join snwd_bpa as b on b.node_key = h.buyer_guid group by company_name order by gross_amount desc; END; /********* End Procedure Script ************/