wiki:AdvancedReports

Version 24 (modified by 193288, 3 years ago) ( diff )

--

Извештај за кој паркинг е најмногу користен

    select i.lokacija, count (r.broj_na_pmesta) as parkingmesto from ime_na_parking as i 
 left join zona as z on i.id_ime = z.ime_na_parking_id_ime
 left join parking_mesto as p on z.id_zona = p.idzona 
 left  join rezervacija as r on p.broj_na_pmesta = r.broj_na_pmesta  
 where (extract (hour from pocetno_vreme) between 1 and 24) and (extract (hour from krajno_vreme) between 1 and 24)
 group by i.lokacija 
 order by parkingmesto desc limit 1

Листа од прекшроци кој начесто се случуваат на ниво на сите паркинзи

select  konstantacija , count( konstantacija) as brpt from kazna as k
join kontrola as kk on kk.id_kazna=k.id_kazna
group by konstantacija
order by brpt desc limit 1

Извештај за кој метод на плаќање е најчесто искористен од страна на корисниците (мобилно или картичка)

    select  tip_plakjanje , count( tip_plakjanje) as brpt from plakjanje
group by tip_plakjanje
order by brpt desc limit 1

Прикажување на статистика кој паркинг носи најголема заработка

select lokacija,
coalesce(sum (date_part('hour',krajno_vreme-pocetno_vreme)),'0')*75 as vreme
from ime_na_parking as inp
left join zona as z on ime_na_parking_id_ime =id_ime
left join parking_mesto as pm on id_zona= idzona
left join rezervacija as rez on rez.broj_na_pmesta=pm.broj_na_pmesta
group by inp.lokacija
order by vreme desc limit 1

Листа на контролери кои што изрекле најмногу казни

select korisnicko_ime,count(korisnicko_ime) as br from kontrola as k2
group by k2.korisnicko_ime
order by br desc limit 1

Извештај за заработка на паркинзите во првите 6 месеци oд тековната година

select distinct * 
FROM
  (
  select lokacija,1 as intt,
coalesce(sum (date_part('hour',krajno_vreme-pocetno_vreme)),'0')*75 as vreme_januari
from ime_na_parking as inp
left join zona as z on ime_na_parking_id_ime =id_ime
left join parking_mesto as pm on id_zona= idzona
left join rezervacija as rez on rez.broj_na_pmesta=pm.broj_na_pmesta
where extract(month from pocetno_vreme)=1 and extract(year from pocetno_vreme)=extract(year from now()) 
group by inp.lokacija
order by vreme_januari desc 
  ) as inp
left join
  (
    select lokacija,1 as intt1,
coalesce(sum (date_part('hour',krajno_vreme-pocetno_vreme)),'0')*75 as vreme_februari
from ime_na_parking as inp
left join zona as z on ime_na_parking_id_ime =id_ime
left join parking_mesto as pm on id_zona= idzona
left join rezervacija as rez on rez.broj_na_pmesta=pm.broj_na_pmesta
where extract(month from pocetno_vreme)=2
group by inp.lokacija
order by vreme_februari desc 
  ) as inpp
  ON
      intt=intt1 or inp.lokacija = inpp.lokacija 
left join  (
  select lokacija,1 as intt2,
coalesce(sum (date_part('hour',krajno_vreme-pocetno_vreme)),'0')*75 as vreme_mart
from ime_na_parking as inp
left join zona as z on ime_na_parking_id_ime =id_ime
left join parking_mesto as pm on id_zona= idzona
left join rezervacija as rez on rez.broj_na_pmesta=pm.broj_na_pmesta
where extract(month from pocetno_vreme)=3
group by inp.lokacija
order by vreme_mart desc 
  ) as inppp
    ON
      intt1=intt2 or inp.lokacija = inpp.lokacija 
 left join  (
  select lokacija,1 as intt3,
coalesce(sum (date_part('hour',krajno_vreme-pocetno_vreme)),'0')*75 as vreme_april
from ime_na_parking as inp
left join zona as z on ime_na_parking_id_ime =id_ime
left join parking_mesto as pm on id_zona= idzona
left join rezervacija as rez on rez.broj_na_pmesta=pm.broj_na_pmesta
where extract(month from pocetno_vreme)=4
group by inp.lokacija
order by vreme_april desc 
  ) as inp1
    ON
     intt3=intt2 or inp1.lokacija = inppp.lokacija     
     left join  (
  select lokacija,1 as intt4,
coalesce(sum (date_part('hour',krajno_vreme-pocetno_vreme)),'0')*75 as vreme_maj
from ime_na_parking as inp
left join zona as z on ime_na_parking_id_ime =id_ime
left join parking_mesto as pm on id_zona= idzona
left join rezervacija as rez on rez.broj_na_pmesta=pm.broj_na_pmesta
where extract(month from pocetno_vreme)=5
group by inp.lokacija
order by vreme_maj desc 
  ) as inp2
    ON
     intt3=intt4 or inp1.lokacija = inp2.lokacija 
     left join  (
  select lokacija,1 as intt5,
coalesce(sum (date_part('hour',krajno_vreme-pocetno_vreme)),'0')*75 as vreme_juni
from ime_na_parking as inp
left join zona as z on ime_na_parking_id_ime =id_ime
left join parking_mesto as pm on id_zona= idzona
left join rezervacija as rez on rez.broj_na_pmesta=pm.broj_na_pmesta
where extract(month from pocetno_vreme)=6
group by inp.lokacija
order by vreme_juni desc 
  ) as inp3
    ON
     intt4=intt5 or inp2.lokacija = inp3.lokacija 
      


Note: See TracWiki for help on using the wiki.