1 | | = Напредни извештаи од базата (SQL и складирани процедури) = |
2 | | |
3 | | == Најпродавана конфигурација == |
4 | | {{{#!sql |
5 | | select * |
6 | | from project."Configuration" as c |
7 | | order by c.quantity_sold desc |
8 | | limit 1; |
9 | | }}} |
10 | | |
11 | | == Најпосакувани продукти од одредена конфигурација == |
12 | | {{{#!sql |
13 | | select c."name", sum(p.quantity_sold) as prodadeno |
14 | | from project."Configuration" as c |
15 | | join project.config_contains_product as ccp on ccp.config_id = c.config_id |
16 | | join project.product as p on p.prod_id = ccp.prod_id |
17 | | group by c."name" |
18 | | order by prodadeno desc |
19 | | limit 1; |
20 | | }}} |
21 | | |
22 | | |
23 | | == 10 најпродавани продукти == |
24 | | {{{#!sql |
25 | | select * |
26 | | from project.product as p |
27 | | order by p.quantity_sold desc |
28 | | limit 10; |
29 | | }}} |
58 | | select count(d.delivery_id) as cnt ,d.distributor_id, d.delivery_id |
59 | | from project.delivery as d |
60 | | where d.status = 'complete' |
61 | | group by d.delivery_id,d.distributor_id |
62 | | ) as d on o.distributor_id = d.distributor_id; |
| 28 | select count(d.delivery_id) as cnt ,d.distributor_id, d.delivery_id |
| 29 | from project.delivery as d |
| 30 | where now() - interval'3 months' <= d."date" |
| 31 | group by d.delivery_id, d.distributor_id |
| 32 | )as d on o.distributor_id = d.distributor_id |
| 33 | group by o.distributor_id |
| 34 | order by Br_Dostaveni_Produkti desc; |