Changes between Version 3 and Version 4 of AdvancedReports


Ignore:
Timestamp:
12/30/22 04:29:50 (23 months ago)
Author:
181213
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • AdvancedReports

    v3 v4  
    11== Напредни извештаи од базата (SQL и складирани процедури)
    22
    3 - Ресторан со најмногу нарачки за последниот Х период?
     3- Ресторан со најмногу нарачки во последните 3 месеци
    44{{{#!sql
    5 SELECT q1.restoran_ime
     5SELECT q1.restoran_ime as restoran, q1.naracki as broj_na_naracki
    66FROM(
    77SELECT r.restoran_ime, COUNT(n.naracka_id) as naracki
     
    1010JOIN obrok as o on m.meni_id=o.meni_id
    1111JOIN se_sostoi_od as sso on o.obrok_id=sso.obrok_id
    12 JOIN naracka as n on sso.naracka_id=n.naracka_id
     12JOIN naracka as n on sso.naracka_id=n.naracka_id
     13where n.naracana_na between (now()-interval '3 months') and now()
    1314GROUP BY r.restoran_ime) q1
    1415WHERE q1.naracki=(SELECT MAX(naracki)FROM (
    15 SELECT r.restoran_ime, COUNT(n.naracka_id) as naracki
     16SELECT r.restoran_ime, COUNT (n.naracka_id) as naracki
    1617FROM restoran as r
    1718JOIN meni as m on r.restoran_id=m.restoran_id
    1819JOIN obrok as o on m.meni_id=o.meni_id
    1920JOIN 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
     21JOIN naracka as n on sso.naracka_id=n.naracka_id
     22where n.naracana_na between (now()-interval '3 months') and now()
     23GROUP BY r.restoran_ime) q2
    2224)
    2325}}}
    24 - Најголем профит?
     26- Ресторан со најголем профит
     27{{{#!sql
     28select 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
     29from restoran r
     30join meni as m on r.restoran_id=m.restoran_id
     31join obrok as o on m.meni_id=o.meni_id
     32join se_sostoi_od as sso on o.obrok_id=sso.obrok_id
     33join naracka as n on sso.naracka_id = n.naracka_id
     34group by r.restoran_id)q1
     35on q1.restoran_id=rr.restoran_id
     36where cena_vkupna=(select max(cena_vkupna) from(
     37select r.restoran_id,sum(sso.cena * sso.kolicina) as cena_vkupna
     38from restoran r
     39join meni as m on r.restoran_id=m.restoran_id
     40join obrok as o on m.meni_id=o.meni_id
     41join se_sostoi_od as sso on o.obrok_id=sso.obrok_id
     42join naracka as n on sso.naracka_id = n.naracka_id
     43group by r.restoran_id
     44)q2)
     45}}}
    2546- Најнарачан производ по ресторан?