| 157 | === Извештај за деловите кои биле нарачани во последните 3 месеци, со нивни категории и производители и количината која била нарачана === |
| 158 | {{{#!sql |
| 159 | select p.id_part, p.part_name, cat.category_name, pm.pm_name, |
| 160 | sum(ocp.quantity_order) as narachani_posledni_3_meseci |
| 161 | from project.part as p |
| 162 | join project.part_manufacturer as pm on p.id_part_manufacturer = pm.id_part_manufacturer |
| 163 | join project.part_is_from_category as pifc on p.id_part = pifc.id_part |
| 164 | join project.category as cat on pifc.id_category = cat.id_category |
| 165 | join project.order_contains_part as ocp on p.id_part = ocp.id_part |
| 166 | join project.order_table as o on ocp.id_order = o.id_order |
| 167 | and |
| 168 | o.order_date between now()-interval'3 months' and now() |
| 169 | group by p.id_part, p.part_name, cat.category_name, pm.pm_name |
| 170 | }}} |