Changes between Version 6 and Version 7 of AdvancedReports


Ignore:
Timestamp:
12/28/22 14:57:01 (2 years ago)
Author:
201084
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • AdvancedReports

    v6 v7  
    169169group by p.id_part, p.part_name, cat.category_name, pm.pm_name
    170170}}}
     171
     172=== Извештај за производителите на авто делови, колку делови од тој производител се продаваат за секоја четвртина од годината ===
     173{{{#!sql
     174select pm.id_part_manufacturer ,pm.pm_name ,
     175coalesce(fq.count_first_quarter,0) as first_quarter, coalesce(sq.count_second_quarter,0) as second_quarter,
     176coalesce(tq.count_third_quarter,0) as third_quarter, coalesce(frq.count_fourth_quarter,0) as fourth_quarter
     177from project.part_manufacturer pm
     178join project.part p on p.id_part_manufacturer = pm.id_part_manufacturer
     179join project.order_contains_part ocp on ocp.id_part = p.id_part
     180join project.order_table ot on ot.id_order = ocp.id_order
     181left join (
     182select pm.id_part_manufacturer ,pm.pm_name , count(ocp.id_part) as count_first_quarter
     183from project.part_manufacturer pm
     184join project.part p on p.id_part_manufacturer = pm.id_part_manufacturer
     185join project.order_contains_part ocp on ocp.id_part = p.id_part
     186join project.order_table ot on ot.id_order = ocp.id_order and ot.order_date between to_date(concat('01-01-',extract(year from now())),'dd-mm-yyyy') and to_date(concat('31-03-',extract(year from now())),'dd-mm-yyyy')
     187group by pm.id_part_manufacturer
     188) as fq on pm.id_part_manufacturer = fq.id_part_manufacturer and pm.pm_name = fq.pm_name
     189left join (
     190select pm.id_part_manufacturer ,pm.pm_name , count(ocp.id_part) as count_second_quarter
     191from project.part_manufacturer pm
     192join project.part p on p.id_part_manufacturer = pm.id_part_manufacturer
     193join project.order_contains_part ocp on ocp.id_part = p.id_part
     194join project.order_table ot on ot.id_order = ocp.id_order and ot.order_date between to_date(concat('01-04-',extract(year from now())),'dd-mm-yyyy') and to_date(concat('30-06-',extract(year from now())),'dd-mm-yyyy')
     195group by pm.id_part_manufacturer
     196) as sq on pm.id_part_manufacturer = sq.id_part_manufacturer and pm.pm_name = sq.pm_name
     197left join (
     198select pm.id_part_manufacturer ,pm.pm_name , count(ocp.id_part) as count_third_quarter
     199from project.part_manufacturer pm
     200join project.part p on p.id_part_manufacturer = pm.id_part_manufacturer
     201join project.order_contains_part ocp on ocp.id_part = p.id_part
     202join project.order_table ot on ot.id_order = ocp.id_order and ot.order_date between to_date(concat('01-07-',extract(year from now())),'dd-mm-yyyy') and to_date(concat('30-09-',extract(year from now())),'dd-mm-yyyy')
     203group by pm.id_part_manufacturer
     204) as tq on pm.id_part_manufacturer = tq.id_part_manufacturer and pm.pm_name = tq.pm_name
     205left join (
     206select pm.id_part_manufacturer ,pm.pm_name , count(ocp.id_part) as count_fourth_quarter
     207from project.part_manufacturer pm
     208join project.part p on p.id_part_manufacturer = pm.id_part_manufacturer
     209join project.order_contains_part ocp on ocp.id_part = p.id_part
     210join project.order_table ot on ot.id_order = ocp.id_order and ot.order_date between to_date(concat('01-10-',extract(year from now())),'dd-mm-yyyy') and to_date(concat('31-12-',extract(year from now())),'dd-mm-yyyy')
     211group by pm.id_part_manufacturer
     212) as frq on pm.id_part_manufacturer = frq.id_part_manufacturer and pm.pm_name = frq.pm_name
     213group by pm.id_part_manufacturer, fq.count_first_quarter, sq.count_second_quarter, tq.count_third_quarter, frq.count_fourth_quarter
     214
     215}}}