========
/* Formatted on 2020/06/17 21:34 (Formatter Plus v4.8.8) */
SELECT p.product_id, p.product_name, p.product_description, p.CATEGORY,
DECODE (p.product_avail, 'Y', 'Yes', 'N', 'No') product_avail,
p.list_price, (SELECT SUM (quantity)
FROM demo_order_items
WHERE product_id = p.product_id) units,
(SELECT SUM (quantity * p.list_price)
FROM demo_order_items
WHERE product_id = p.product_id) sales,
(SELECT COUNT (o.customer_id)
FROM demo_orders o, demo_order_items t
WHERE o.order_id = t.order_id
AND t.product_id = p.product_id
GROUP BY p.product_id) customers,
(SELECT MAX (o.order_timestamp) od
FROM demo_orders o, demo_order_items i
WHERE o.order_id = i.order_id
AND i.product_id = p.product_id) last_date_sold,
p.product_id img,
apex_util.prepare_url
(p_url => 'f?p='
|| :app_id
|| ':6:'
|| :app_session
|| '::::P6_PRODUCT_ID,P6_BRANCH:'
|| p.product_id
|| ','
|| 3,
p_dialog => 'null'
) icon_link,
DECODE
(NVL (DBMS_LOB.getlength (p.product_image), 0),
0, NULL,
'<img alt="'
|| apex_escape.html_attribute (p.product_name)
|| '" title="'
|| apex_escape.html_attribute (p.product_name)
|| '" style="border: 4px solid #CCC; -moz-border-radius: 4px; -webkit-border-radius: 4px;" '
|| 'src="'
|| apex_util.get_blob_file_src ('P6_PRODUCT_IMAGE', p.product_id)
|| '" height="75" width="75" />'
) detail_img,
DECODE
(NVL (DBMS_LOB.getlength (p.product_image), 0),
0, NULL,
apex_util.get_blob_file_src ('P6_PRODUCT_IMAGE', p.product_id)
) detail_img_no_style,
tags
FROM demo_product_info p
No comments:
Post a Comment