Changes between Version 6 and Version 7 of AdvancedReports


Ignore:
Timestamp:
12/27/22 20:59:59 (19 months ago)
Author:
201065
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • AdvancedReports

    v6 v7  
    7070select q1.locationname, prihod-odliv as profit from
    7171(
    72         select l.locationid, l.locationname, sum(i.price*i.quantity) as prihod from locations l
     72        select l.locationid, l.locationname, coalesce(sum(i.price*i.quantity), 0) as prihod from locations l
    7373        left join storedarticles s on s.locationid=l.locationid
    7474        left join invoicedarticles i on i.articleid=s.articleid
     
    7979full outer join
    8080(
    81         select l.locationid, l.locationname, sum(o.price*o.quantity) as odliv from locations l
     81        select l.locationid, l.locationname, coalesce(sum(o.price*o.quantity), 0) as odliv from locations l
    8282        left join orderedarticles o on o.locationid=l.locationid
    8383        left join orders o2 on o2.orderid=o.orderid and o2.datecreated between now()-interval '1 year' and now()
     
    8585       
    8686) q2 on q2.locationid=q1.locationid
    87 
    8887}}}
    8988
     
    109108
    110109}}}
     110
     111===  Извештај за набавувачите со најголема заработка===
     112
     113{{{#!sql
     114        select s.supplierinfo, u.firstname, u.lastname, u.username, coalesce(sum(o2.quantity), 0) as koldostavena, coalesce(sum(o2.quantity*o2.price)) as zarabotkasupp from suppliers s
     115                left join users u on u.userid=s.userid
     116                left join orders o on o.supplieruserid=s.userid and (o.status='Delivered' or o.status='Processed')
     117                left join orderedarticles o2 on o2.orderid=o.orderid and (o2.articlestatus='Delivered' or o2.articlestatus='Processed')
     118                group by s.userid, u.userid
     119                order by zarabotkasupp desc
     120
     121
     122}}}