Changes between Version 3 and Version 4 of AdvancedReports


Ignore:
Timestamp:
12/28/22 12:19:25 (2 years ago)
Author:
201084
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • AdvancedReports

    v3 v4  
    103103=== Извештај за сите делови, со нивни категории и производители, и количината која била нарачана од овие делови во секој од последните 3 месеци. ===
    104104{{{#!sql
    105 select p.id_part, p.part_name, cat.category_name, pm.pm_name, f.narachani_vo_ovoj_mesec as narachani_ovoj_mesec, s.narachani_vo_prethoden_mesec as narachani_prethoden_mesec, t.narachani_vo_predprethoden_mesec as narachani_predprethoden_mesec
     105select p.id_part, p.part_name, cat.category_name, pm.pm_name,
     106coalesce (f.narachani_vo_ovoj_mesec,0) as narachani_ovoj_mesec,
     107coalesce (s.narachani_vo_prethoden_mesec,0) as narachani_prethoden_mesec,
     108coalesce (t.narachani_vo_predprethoden_mesec,0) as narachani_predprethoden_mesec
    106109from project.part as p
    107110join project.part_manufacturer as pm on p.id_part_manufacturer = pm.id_part_manufacturer
    108111join project.part_is_from_category as pifc on p.id_part = pifc.id_part
    109112join project.category as cat on pifc.id_category = cat.id_category
    110 left join project.order_contains_part as ocp on p.id_part = ocp.id_part
    111 left join project.order_table as o on ocp.id_order = o.id_order
     113join project.order_contains_part as ocp on p.id_part = ocp.id_part
     114join project.order_table as o on ocp.id_order = o.id_order
    112115left join (
    113116select p.id_part, p.part_name, cat.category_name, pm.pm_name,
    114        count(o.id_order) as narachani_vo_ovoj_mesec
     117       sum(ocp.quantity_order) as narachani_vo_ovoj_mesec
    115118from project.part as p
    116119join project.part_manufacturer as pm on p.id_part_manufacturer = pm.id_part_manufacturer
    117120join project.part_is_from_category as pifc on p.id_part = pifc.id_part
    118121join project.category as cat on pifc.id_category = cat.id_category
    119 left join project.order_contains_part as ocp on p.id_part = ocp.id_part
    120 left join project.order_table as o on ocp.id_order = o.id_order
     122join project.order_contains_part as ocp on p.id_part = ocp.id_part
     123join project.order_table as o on ocp.id_order = o.id_order
    121124                                  and
    122125                              extract(month from o.order_date) = extract(month from now()) and extract(year from o.order_date) = extract(year from now())
     
    125128left join (
    126129select p.id_part, p.part_name, cat.category_name, pm.pm_name,
    127        count(o.id_order) as narachani_vo_prethoden_mesec
     130       sum(ocp.quantity_order) as narachani_vo_prethoden_mesec
    128131from project.part as p
    129132join project.part_manufacturer as pm on p.id_part_manufacturer = pm.id_part_manufacturer
    130133join project.part_is_from_category as pifc on p.id_part = pifc.id_part
    131134join project.category as cat on pifc.id_category = cat.id_category
    132 left join project.order_contains_part as ocp on p.id_part = ocp.id_part
    133 left join project.order_table as o on ocp.id_order = o.id_order
     135join project.order_contains_part as ocp on p.id_part = ocp.id_part
     136join project.order_table as o on ocp.id_order = o.id_order
    134137                                  and
    135138                              extract(month from o.order_date) = extract(month from now()-interval'1 month') and extract(year from o.order_date) = extract(year from now()-interval'1 month')
    136 group by p.id_part, p.part_name, cat.category_name, pm.pm_name
     139group by p.id_part, p.part_name, cat.category_name, pm.pm_name 
    137140) as s on p.id_part = s.id_part and pm.pm_name = s.pm_name
    138141left join (
    139142select p.id_part, p.part_name, cat.category_name, pm.pm_name,
    140        count(o.id_order) as narachani_vo_predprethoden_mesec
     143       sum(ocp.quantity_order) as narachani_vo_predprethoden_mesec
    141144from project.part as p
    142145join project.part_manufacturer as pm on p.id_part_manufacturer = pm.id_part_manufacturer
    143146join project.part_is_from_category as pifc on p.id_part = pifc.id_part
    144147join project.category as cat on pifc.id_category = cat.id_category
    145 left join project.order_contains_part as ocp on p.id_part = ocp.id_part
    146 left join project.order_table as o on ocp.id_order = o.id_order
     148join project.order_contains_part as ocp on p.id_part = ocp.id_part
     149join project.order_table as o on ocp.id_order = o.id_order
    147150                                  and
    148151                              extract(month from o.order_date) = extract(month from now()-interval'2 month') and extract(year from o.order_date) = extract(year from now()-interval'2 month')
    149 group by p.id_part, p.part_name, cat.category_name, pm.pm_name
     152group by p.id_part, p.part_name, cat.category_name, pm.pm_name 
    150153) as t on p.id_part = t.id_part and pm.pm_name = t.pm_name
    151154group by p.id_part, p.part_name, cat.category_name, pm.pm_name, f.narachani_vo_ovoj_mesec, s.narachani_vo_prethoden_mesec, t.narachani_vo_predprethoden_mesec
    152155
    153 
    154 
    155156}}}