ui: update ProductPerformanceProfitability page to enhance table views and tabs management
This commit is contained in:
@@ -825,20 +825,68 @@ StockAgg AS (
|
||||
WHERE s.stock_date = (SELECT stock_date FROM LatestStockDate)
|
||||
GROUP BY s.product_code, s.color_code, s.yaka_kodu
|
||||
),
|
||||
Dim AS (
|
||||
SELECT DISTINCT ON (product_code, color_code, yaka_kodu)
|
||||
product_code,
|
||||
color_code,
|
||||
yaka_kodu,
|
||||
item_description,
|
||||
kategori,
|
||||
seri,
|
||||
yas_grubu,
|
||||
askili_yan,
|
||||
urun_ilk_grubu,
|
||||
urun_ana_grubu,
|
||||
urun_alt_grubu
|
||||
FROM (
|
||||
SELECT
|
||||
product_code,
|
||||
color_code,
|
||||
yaka_kodu,
|
||||
item_description,
|
||||
kategori,
|
||||
seri,
|
||||
yas_grubu,
|
||||
askili_yan,
|
||||
urun_ilk_grubu,
|
||||
urun_ana_grubu,
|
||||
urun_alt_grubu,
|
||||
1 AS src_rank
|
||||
FROM mk_product_performance_kpi_daily
|
||||
WHERE kpi_date = (SELECT MAX(kpi_date) FROM mk_product_performance_kpi_daily)
|
||||
UNION ALL
|
||||
SELECT
|
||||
product_code,
|
||||
color_code,
|
||||
yaka_kodu,
|
||||
MAX(item_description) AS item_description,
|
||||
MAX(kategori) AS kategori,
|
||||
MAX(seri) AS seri,
|
||||
MAX(yas_grubu) AS yas_grubu,
|
||||
MAX(askili_yan) AS askili_yan,
|
||||
MAX(urun_ilk_grubu) AS urun_ilk_grubu,
|
||||
MAX(urun_ana_grubu) AS urun_ana_grubu,
|
||||
MAX(urun_alt_grubu) AS urun_alt_grubu,
|
||||
2 AS src_rank
|
||||
FROM mk_product_performance_sales_daily
|
||||
GROUP BY product_code, color_code, yaka_kodu
|
||||
) x
|
||||
ORDER BY product_code, color_code, yaka_kodu, src_rank
|
||||
),
|
||||
StockOnly AS (
|
||||
SELECT
|
||||
s.product_code,
|
||||
s.color_code,
|
||||
s.yaka_kodu,
|
||||
'STOK'::text AS market_key,
|
||||
MAX(s.item_description) AS item_description,
|
||||
MAX(s.kategori) AS kategori,
|
||||
MAX(s.seri) AS seri,
|
||||
MAX(s.yas_grubu) AS yas_grubu,
|
||||
MAX(s.askili_yan) AS askili_yan,
|
||||
MAX(s.urun_ilk_grubu) AS urun_ilk_grubu,
|
||||
MAX(s.urun_ana_grubu) AS urun_ana_grubu,
|
||||
MAX(s.urun_alt_grubu) AS urun_alt_grubu,
|
||||
COALESCE(MAX(d.item_description),'') AS item_description,
|
||||
COALESCE(MAX(d.kategori),'') AS kategori,
|
||||
COALESCE(MAX(d.seri),'') AS seri,
|
||||
COALESCE(MAX(d.yas_grubu),'') AS yas_grubu,
|
||||
COALESCE(MAX(d.askili_yan),'') AS askili_yan,
|
||||
COALESCE(MAX(d.urun_ilk_grubu),'') AS urun_ilk_grubu,
|
||||
COALESCE(MAX(d.urun_ana_grubu),'') AS urun_ana_grubu,
|
||||
COALESCE(MAX(d.urun_alt_grubu),'') AS urun_alt_grubu,
|
||||
NULL::date AS first_sale_date,
|
||||
NULL::date AS last_sale_date,
|
||||
''::text AS last_ref_number,
|
||||
@@ -847,6 +895,10 @@ StockOnly AS (
|
||||
0::integer AS customer_count_total,
|
||||
0::integer AS invoice_count_total
|
||||
FROM mk_product_performance_stock_daily s
|
||||
LEFT JOIN Dim d
|
||||
ON d.product_code = s.product_code
|
||||
AND d.color_code = s.color_code
|
||||
AND d.yaka_kodu = s.yaka_kodu
|
||||
WHERE s.stock_date = (SELECT stock_date FROM LatestStockDate)
|
||||
AND NOT EXISTS (
|
||||
SELECT 1
|
||||
|
||||
Reference in New Issue
Block a user