Version 14 (modified by 3 years ago) ( diff ) | ,
---|
Најпопуларен производ во wishlists на корисниците во изминатите 6 месеци
select p."name" as Product, p.description as Description from project.product as p join( select ptw.prod_id, count(ptw.prod_id) as cnt from project.product_to_wishlist as ptw group by ptw.prod_id ) as pw on p.prod_id = pw.prod_id join( select u.time_stamp, u.product_id from project.updates as u group by u.product_id, u.time_stamp )as u on u.product_id = p.prod_id where now()-interval'6 months' <= u.time_stamp group by p."name", p.description, pw.cnt, p.prod_id, u.time_stamp order by pw.cnt desc limit 1;
Доставувач со највеќе доставени продукти во изминатите 3 месеци
select o.distributor_id as Dostavuvac , sum(d.cnt) as Br_Dostaveni_Produkti from project.distributor as o join ( select count(d.delivery_id) as cnt ,d.distributor_id, d.delivery_id from project.delivery as d where status='Delivered' AND now() - interval'3 months' <= d."date" group by d.delivery_id, d.distributor_id )as d on o.distributor_id = d.distributor_id group by o.distributor_id order by Br_Dostaveni_Produkti desc limit 1;
Note:
See TracWiki
for help on using the wiki.