Changes between Version 2 and Version 3 of AdvancedReports


Ignore:
Timestamp:
12/27/22 22:39:48 (2 years ago)
Author:
201084
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • AdvancedReports

    v2 v3  
    100100                )
    101101}}}
     102
     103=== Извештај за сите делови, со нивни категории и производители, и количината која била нарачана од овие делови во секој од последните 3 месеци. ===
     104{{{#!sql
     105select 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
     106from project.part as p
     107join project.part_manufacturer as pm on p.id_part_manufacturer = pm.id_part_manufacturer
     108join project.part_is_from_category as pifc on p.id_part = pifc.id_part
     109join project.category as cat on pifc.id_category = cat.id_category
     110left join project.order_contains_part as ocp on p.id_part = ocp.id_part
     111left join project.order_table as o on ocp.id_order = o.id_order
     112left join (
     113select p.id_part, p.part_name, cat.category_name, pm.pm_name,
     114       count(o.id_order) as narachani_vo_ovoj_mesec
     115from project.part as p
     116join project.part_manufacturer as pm on p.id_part_manufacturer = pm.id_part_manufacturer
     117join project.part_is_from_category as pifc on p.id_part = pifc.id_part
     118join project.category as cat on pifc.id_category = cat.id_category
     119left join project.order_contains_part as ocp on p.id_part = ocp.id_part
     120left join project.order_table as o on ocp.id_order = o.id_order
     121                                  and
     122                              extract(month from o.order_date) = extract(month from now()) and extract(year from o.order_date) = extract(year from now())
     123group by p.id_part, p.part_name, cat.category_name, pm.pm_name
     124) as f on p.id_part = f.id_part and pm.pm_name = f.pm_name
     125left join (
     126select p.id_part, p.part_name, cat.category_name, pm.pm_name,
     127       count(o.id_order) as narachani_vo_prethoden_mesec
     128from project.part as p
     129join project.part_manufacturer as pm on p.id_part_manufacturer = pm.id_part_manufacturer
     130join project.part_is_from_category as pifc on p.id_part = pifc.id_part
     131join project.category as cat on pifc.id_category = cat.id_category
     132left join project.order_contains_part as ocp on p.id_part = ocp.id_part
     133left join project.order_table as o on ocp.id_order = o.id_order
     134                                  and
     135                              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')
     136group by p.id_part, p.part_name, cat.category_name, pm.pm_name
     137) as s on p.id_part = s.id_part and pm.pm_name = s.pm_name
     138left join (
     139select p.id_part, p.part_name, cat.category_name, pm.pm_name,
     140       count(o.id_order) as narachani_vo_predprethoden_mesec
     141from project.part as p
     142join project.part_manufacturer as pm on p.id_part_manufacturer = pm.id_part_manufacturer
     143join project.part_is_from_category as pifc on p.id_part = pifc.id_part
     144join project.category as cat on pifc.id_category = cat.id_category
     145left join project.order_contains_part as ocp on p.id_part = ocp.id_part
     146left join project.order_table as o on ocp.id_order = o.id_order
     147                                  and
     148                              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')
     149group by p.id_part, p.part_name, cat.category_name, pm.pm_name
     150) as t on p.id_part = t.id_part and pm.pm_name = t.pm_name
     151group 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
     152
     153
     154
     155}}}