Changes between Version 3 and Version 4 of AdvancedReports
- Timestamp:
- 12/30/22 04:29:50 (23 months ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
AdvancedReports
v3 v4 1 1 == Напредни извештаи од базата (SQL и складирани процедури) 2 2 3 - Ресторан со најмногу нарачки за последниот Х период?3 - Ресторан со најмногу нарачки во последните 3 месеци 4 4 {{{#!sql 5 SELECT q1.restoran_ime 5 SELECT q1.restoran_ime as restoran, q1.naracki as broj_na_naracki 6 6 FROM( 7 7 SELECT r.restoran_ime, COUNT(n.naracka_id) as naracki … … 10 10 JOIN obrok as o on m.meni_id=o.meni_id 11 11 JOIN se_sostoi_od as sso on o.obrok_id=sso.obrok_id 12 JOIN naracka as n on sso.naracka_id=n.naracka_id 12 JOIN naracka as n on sso.naracka_id=n.naracka_id 13 where n.naracana_na between (now()-interval '3 months') and now() 13 14 GROUP BY r.restoran_ime) q1 14 15 WHERE q1.naracki=(SELECT MAX(naracki)FROM ( 15 SELECT r.restoran_ime, COUNT (n.naracka_id) as naracki16 SELECT r.restoran_ime, COUNT (n.naracka_id) as naracki 16 17 FROM restoran as r 17 18 JOIN meni as m on r.restoran_id=m.restoran_id 18 19 JOIN obrok as o on m.meni_id=o.meni_id 19 20 JOIN se_sostoi_od as sso on o.obrok_id=sso.obrok_id 20 JOIN naracka as n on sso.naracka_id=n.naracka_id 21 GROUP BY r.restoran_ime) q1 21 JOIN naracka as n on sso.naracka_id=n.naracka_id 22 where n.naracana_na between (now()-interval '3 months') and now() 23 GROUP BY r.restoran_ime) q2 22 24 ) 23 25 }}} 24 - Најголем профит? 26 - Ресторан со најголем профит 27 {{{#!sql 28 select rr.restoran_ime as restoran, q1.cena_vkupna as profit from restoran rr join(select r.restoran_id,sum(sso.cena * sso.kolicina) as cena_vkupna 29 from restoran r 30 join meni as m on r.restoran_id=m.restoran_id 31 join obrok as o on m.meni_id=o.meni_id 32 join se_sostoi_od as sso on o.obrok_id=sso.obrok_id 33 join naracka as n on sso.naracka_id = n.naracka_id 34 group by r.restoran_id)q1 35 on q1.restoran_id=rr.restoran_id 36 where cena_vkupna=(select max(cena_vkupna) from( 37 select r.restoran_id,sum(sso.cena * sso.kolicina) as cena_vkupna 38 from restoran r 39 join meni as m on r.restoran_id=m.restoran_id 40 join obrok as o on m.meni_id=o.meni_id 41 join se_sostoi_od as sso on o.obrok_id=sso.obrok_id 42 join naracka as n on sso.naracka_id = n.naracka_id 43 group by r.restoran_id 44 )q2) 45 }}} 25 46 - Најнарачан производ по ресторан?