Changes between Version 1 and Version 2 of AdvancedReports


Ignore:
Timestamp:
12/27/22 15:07:07 (2 years ago)
Author:
201084
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • AdvancedReports

    v1 v2  
    6565        order by vkupna_suma desc
    6666}}}
     67=== Извештај за сите категории и за кој прозиводител на коли биле купени највеќе делови од таа категорија ===
     68{{{#!sql
     69select c.id_category, c.category_name, cm.id_car_manufacturer , cm.cm_name ,
     70count(ocp.id_part) as category_by_car
     71from project.category as c
     72left join project.part_is_from_category pifc on pifc.id_category = c.id_category
     73left join project.part p on p.id_part = pifc.id_part
     74left join project.order_contains_part ocp on ocp.id_part = p.id_part
     75left join project.order_table ot on ot.id_order = ocp.id_order
     76left join project.users_table ut on ut.id_user = ot.id_user
     77left join project.car_sample cs on cs.id_user = ut.id_user
     78left join project.car c2 on c2.id_car = cs.id_car
     79left join project.car_manufacturer cm on cm.id_car_manufacturer = c2.id_car_manufacturer
     80group by c.id_category,cm.id_car_manufacturer 
     81order by category_by_car desc
     82}}}
     83
     84=== Извештај за најкупуван артикл, во која количина и од која категорија е истиот ===
     85{{{#!sql
     86select c.category_name , p.part_name , coalesce(sum(ocp2.quantity_order),0) as maxkol from project.part p
     87        left join project.part_is_from_category pifc on pifc.id_part = p.id_part
     88        left join project.category c on c.id_category = pifc.id_category 
     89        left join project.order_contains_part ocp2 on ocp2.id_part = p.id_part
     90        group by c.id_category , p.id_part 
     91        having coalesce(sum(ocp2.quantity_order), 0)=(
     92                select max(maxkol) from
     93                (
     94                        select coalesce(sum(ocp2.quantity_order),0) as maxkol from project.part p
     95                        left join project.part_is_from_category pifc on pifc.id_part = p.id_part
     96                        left join project.category c on c.id_category = pifc.id_category 
     97                        left join project.order_contains_part ocp2 on ocp2.id_part = p.id_part
     98                        group by c.id_category , p.id_part
     99                ) q1
     100                )
     101}}}