Changes between Version 3 and Version 4 of AdvancedReports


Ignore:
Timestamp:
12/27/22 11:39:58 (19 months ago)
Author:
201091
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • AdvancedReports

    v3 v4  
    6464                                )odliv  on odliv.categoryid=c.categoryid)
    6565}}}
     66
     67===  Извештај за профитот на сите магацини според набавени артикли и продадени артикли во период од една година===
     68
     69{{{#!sql
     70select q1.locationname, prihod-odliv as profit from
     71(
     72        select l.locationid, l.locationname, sum(i.price*i.quantity) as prihod from locations l
     73        left join storedarticles s on s.locationid=l.locationid
     74        left join invoicedarticles i on i.articleid=s.articleid
     75        left join invoices i2 on i2.invoiceid=i.invoiceid and i2.datecreate between now()-interval '1 year' and now()
     76        group by l.locationid
     77       
     78) as q1
     79full outer join
     80(
     81        select l.locationid, l.locationname, sum(o.price*o.quantity) as odliv from locations l
     82        left join orderedarticles o on o.locationid=l.locationid
     83        left join orders o2 on o2.orderid=o.orderid and o2.datecreated between now()-interval '1 year' and now()
     84        group by l.locationid
     85       
     86) q2 on q2.locationid=q1.locationid
     87
     88}}}