Sunday, February 23, 2020

Top Rank

WITH cte_products AS (
select pack_size,b_code,p_name,nvl(totww-ttee,0) ssss,
RANK() OVER(ORDER BY nvl(totww-ttee,0) DESC) price_rank
from
(
 select c.pack_size,b.b_code,c.p_name,nvl(sum(qty),0) totww, nvl(sum(rqty),0)  ttee
     from jpldba.INVOICE_MAST@fremote10g a, jpldba.INVOICE_CHILD@fremote10g b, jpldba.price@fremote10g c
         where a.inv_no=b.inv_no
             and b.b_code=c.b_code
               and a.empcode='CTG169'
                 --and b.b_code='HSTS2'
                 and inv_date between '01-FEB-20' and '28-FEB-20'
                     group by c.pack_size,b.b_code,c.p_name
))
SELECT
pack_size,
b_code,
 p_name,
 ssss,
 price_rank
FROM
 cte_products
WHERE
 price_rank <= 5
 order by price_rank
/

No comments:

Post a Comment

To generate a PDF using JavaScript in Oracle APEX from a collection

  To generate a PDF using JavaScript in Oracle APEX from a collection, you can follow these steps: 1. Create a button or link on your APEX p...