Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagesql
select
c.caption as "Группа",
m.title as "Бренд",
p.title as "Товар",
p.price as "Цена",
pd.fixed_price as "РРЦ",  
round((p.price - pd.fixed_price)::numeric, 2) as "Откл.",
pr.title as "Прайс",   
(select e.title from c_exists e where pd.is_exists = e.id) as "Наличие в прайсе" 
from product p, product_category c, product_category_connect pcc, 
price_detail pd,
c_manufacture m, price pr       
where pd.product_id = p.id
and m.code = p.manuf_code
and pr.id = pd.price_id
and pcc.cat_id = c.id
and pcc.prod_id = p.id
and pcc.is_main = 1    
and pr.use_rc = 1
and pr.is_active = 1
and pd.fixed_price > 0             
and pd.fixed_price <> p.price
order by p.price - pd.fixed_price desc    

Пример отчета по товарам, у которых маржа больше 100р и наценка больше

...

30%, при этом цена равна или меньше конкурентов

Code Block
languagesql
select p.id as ID, pc.caption as "Группа", m.title as "Бренд", 
p.title as "Товар", p.article as "Модель",
round(p.price::numeric, 2) as "Цена", round(p.input_price::numeric, 2) as "Опт", 
round(((p.price - p.input_price)/p.price * 100)::numeric, 2) as "Рент. %",
round((p.price - p.input_price)::numeric, 2) as "Маржа",  
ppr.title as "Поставщик",
pe.title as "Наличие",
(select string_agg(concat(round(pd.price::numeric, 2), ' ', cr.code, ' ', e.title, 
    ' ост:', pd.exists_text, ' --> ', pr.title), chr(10))
 from price_detail pd, price pr, curr cr, c_exists e where
    pr.id = pd.price_id and pd.is_exists <> 2 and pr.price_type in (1, 3) 
    and pd.product_id = p.id 
    and pd.price_id <> p.price_id and cr.id = pd.price_curr_id and e.id = pd.is_exists) 
 as "Другие поставщики"

from product p, product_category pc, product_category_connect pcc,
c_manufacture m, price ppr, c_exists pe 
where 
pcc.prod_id = p.id and pcc.cat_id = pc.id and pcc.is_main = 1
and p.price_id = ppr.id and pe.id = p.is_exists
and m.code = p.manuf_code
and p.input_price > 0 and p.price > 0 and p.is_exists <> 2
and p.price_compare in (1,2)
and p.price - p.input_price >= 100
and (p.price - p.input_price)/p.price * 100 >= 30
order by p.price - p.input_price desc