Changes between Initial Version and Version 1 of AdvancedReports


Ignore:
Timestamp:
01/19/22 18:46:48 (2 years ago)
Author:
193230
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • AdvancedReports

    v1 v1  
     1= Напредни извештаи од базата (SQL и складирани процедури)
     2
     3= Извештај за секоја продавница, бројот на производи во неа, вкупната вредност на производите, просечна цена по производ и вкупно направени нарачки во последните 3 месеци
     4
     5{{{#!sql
     6select os.names, os.store_id,
     7coalesce((
     8select count(pis.product_in_store_id)
     9        from online_stores as os
     10        join product_in_store as pis on os.store_id=pis.store_id
     11        ),0) as vkupno_proizvodi,
     12(
     13select sum(p.price)
     14        from online_stores as os
     15        join product_in_store as pis on os.store_id=pis.store_id
     16        join price as p on pis.product_in_store_id=p.product_in_store_id
     17       
     18) as vkupna_vrednost,
     19(
     20select avg(p.price)
     21
     22
     23        from online_stores as os
     24        join product_in_store as pis on os.store_id=pis.store_id
     25        join price as p on pis.product_in_store_id=p.product_in_store_id
     26       
     27) as prosek_vrednost,
     28(
     29select count(sb.shopping_id)
     30        from online_stores as os
     31        join product_in_store as pis on os.store_id=pis.product_id
     32        join orders as ord on pis.product_in_store_id=ord.product_in_store_id
     33        join shopping_bag as sb on ord.shopping_id=sb.shopping_id
     34        where sb.order_date between now() - interval '3 months' and now()
     35) as vkupno_naracki
     36
     37       
     38from online_stores as os
     39group by 1, 2
     40
     41        }}}
     42
     43== Вработен кој извршил достава на најмногу нарачки
     44{{{#!sql
     45create view vkupen_broj_naracki as
     46
     47select se.shipping_employee_id, u.user_name, u.surname, count(s.shipping_id) as broj_naracki
     48from shipping_employee as se
     49join users as u on se.user_id=u.user_id
     50join shipping as s on se.user_id=s.user_id
     51join shopping_bag as sb on s.shopping_id=sb.shopping_id
     52
     53group by 1, 2, 3;
     54
     55select vbn.shipping_employee_id, vbn.user_name, vbn.surname, vbn.broj_naracki as najmnogu_naracki
     56from vkupen_broj_naracki as vbn
     57where vbn.broj_naracki = (select max(broj_naracki) from vkupen_broj_naracki);
     58}}}