Changes between Version 3 and Version 4 of AdvancedReports
- Timestamp:
- 12/28/22 12:19:25 (2 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
AdvancedReports
v3 v4 103 103 === Извештај за сите делови, со нивни категории и производители, и количината која била нарачана од овие делови во секој од последните 3 месеци. === 104 104 {{{#!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 105 select p.id_part, p.part_name, cat.category_name, pm.pm_name, 106 coalesce (f.narachani_vo_ovoj_mesec,0) as narachani_ovoj_mesec, 107 coalesce (s.narachani_vo_prethoden_mesec,0) as narachani_prethoden_mesec, 108 coalesce (t.narachani_vo_predprethoden_mesec,0) as narachani_predprethoden_mesec 106 109 from project.part as p 107 110 join project.part_manufacturer as pm on p.id_part_manufacturer = pm.id_part_manufacturer 108 111 join project.part_is_from_category as pifc on p.id_part = pifc.id_part 109 112 join project.category as cat on pifc.id_category = cat.id_category 110 leftjoin project.order_contains_part as ocp on p.id_part = ocp.id_part111 leftjoin project.order_table as o on ocp.id_order = o.id_order113 join project.order_contains_part as ocp on p.id_part = ocp.id_part 114 join project.order_table as o on ocp.id_order = o.id_order 112 115 left join ( 113 116 select p.id_part, p.part_name, cat.category_name, pm.pm_name, 114 count(o.id_order) as narachani_vo_ovoj_mesec117 sum(ocp.quantity_order) as narachani_vo_ovoj_mesec 115 118 from project.part as p 116 119 join project.part_manufacturer as pm on p.id_part_manufacturer = pm.id_part_manufacturer 117 120 join project.part_is_from_category as pifc on p.id_part = pifc.id_part 118 121 join project.category as cat on pifc.id_category = cat.id_category 119 leftjoin project.order_contains_part as ocp on p.id_part = ocp.id_part120 leftjoin project.order_table as o on ocp.id_order = o.id_order122 join project.order_contains_part as ocp on p.id_part = ocp.id_part 123 join project.order_table as o on ocp.id_order = o.id_order 121 124 and 122 125 extract(month from o.order_date) = extract(month from now()) and extract(year from o.order_date) = extract(year from now()) … … 125 128 left join ( 126 129 select p.id_part, p.part_name, cat.category_name, pm.pm_name, 127 count(o.id_order)as narachani_vo_prethoden_mesec130 sum(ocp.quantity_order) as narachani_vo_prethoden_mesec 128 131 from project.part as p 129 132 join project.part_manufacturer as pm on p.id_part_manufacturer = pm.id_part_manufacturer 130 133 join project.part_is_from_category as pifc on p.id_part = pifc.id_part 131 134 join project.category as cat on pifc.id_category = cat.id_category 132 leftjoin project.order_contains_part as ocp on p.id_part = ocp.id_part133 leftjoin project.order_table as o on ocp.id_order = o.id_order135 join project.order_contains_part as ocp on p.id_part = ocp.id_part 136 join project.order_table as o on ocp.id_order = o.id_order 134 137 and 135 138 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 139 group by p.id_part, p.part_name, cat.category_name, pm.pm_name 137 140 ) as s on p.id_part = s.id_part and pm.pm_name = s.pm_name 138 141 left join ( 139 142 select p.id_part, p.part_name, cat.category_name, pm.pm_name, 140 count(o.id_order)as narachani_vo_predprethoden_mesec143 sum(ocp.quantity_order) as narachani_vo_predprethoden_mesec 141 144 from project.part as p 142 145 join project.part_manufacturer as pm on p.id_part_manufacturer = pm.id_part_manufacturer 143 146 join project.part_is_from_category as pifc on p.id_part = pifc.id_part 144 147 join project.category as cat on pifc.id_category = cat.id_category 145 leftjoin project.order_contains_part as ocp on p.id_part = ocp.id_part146 leftjoin project.order_table as o on ocp.id_order = o.id_order148 join project.order_contains_part as ocp on p.id_part = ocp.id_part 149 join project.order_table as o on ocp.id_order = o.id_order 147 150 and 148 151 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 152 group by p.id_part, p.part_name, cat.category_name, pm.pm_name 150 153 ) as t on p.id_part = t.id_part and pm.pm_name = t.pm_name 151 154 group 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 155 153 154 155 156 }}}