Changes between Version 19 and Version 20 of AdvancedReports


Ignore:
Timestamp:
01/26/22 03:59:01 (3 years ago)
Author:
195115
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • AdvancedReports

    v19 v20  
    44
    55{{{#!sql
    6 select distinct f.firm_name,
    7     case when tabelaQuarter.quarter=1 then tabelaSuma.count else 0 end as prv_kvartal_suma,
    8     case when tabelaQuarter.quarter=2 then tabelaSuma.count  else 0 end as vtor_kvartal,
    9     case when tabelaQuarter.quarter=3 then tabelaSuma.count  else 0 end as tret_kvartal,
    10     case when tabelaQuarter.quarter=4 then tabelaSuma.count  else 0 end as cetvrt_kvartal,
    11        
    12     case when tabelaQuarter.quarter=1 then tabelaSuma.sum else 0 end as prv_kvartal_suma,
    13     case when tabelaQuarter.quarter=2 then tabelaSuma.sum  else 0 end as vtor_kvartal_suma,
    14     case when tabelaQuarter.quarter=3 then tabelaSuma.sum  else 0 end as tret_kvartal_suma,
    15     case when tabelaQuarter.quarter=4 then tabelaSuma.sum  else 0 end as cetvrt_kvartal_suma
    16        
    17        
     6select distinct(f.firm_id) as firma,
     7    case when tabelaQuarter.quarter=1 then tabelaSuma.broj_kupeni else 0 end as prv_kvartal_kupeni,
     8    case when tabelaQuarter.quarter=2 then tabelaSuma.broj_kupeni  else 0 end as vtor_kvartal_kupeni,
     9    case when tabelaQuarter.quarter=3 then tabelaSuma.broj_kupeni  else 0 end as tret_kvartal_kupeni,
     10    case when tabelaQuarter.quarter=4 then tabelaSuma.broj_kupeni  else 0 end as cetvrt_kvartal_kupeni,
     11     
     12    (case when tabelaQuarter.quarter=1 then tabelaSuma.sum else 0 end) as prv_kvartal_suma,
     13    (case when tabelaQuarter.quarter=2 then tabelaSuma.sum  else 0 end) as vtor_kvartal_suma,
     14    (case when tabelaQuarter.quarter=3 then tabelaSuma.sum  else 0 end) as tret_kvartal_suma,
     15    (case when tabelaQuarter.quarter=4 then tabelaSuma.sum  else 0 end) as cetvrt_kvartal_suma
    1816       
    1917    from firm as f
    20     join auditorium as a on a.firm_id = f.firm_id
     18        join auditorium as a on a.firm_id = f.firm_id
    2119    join gives as g on g.auditorium_id = a.auditorium_id
    2220    join movieprojection as mp on mp.projection_id = g.projection_id
    2321    join reservation as r on r.projection_id = mp.projection_id
     22    join(
     23    select extract(quarter from reservation_date) as quarter
     24    from reservation
     25    ) as tabelaQuarter on tabelaQuarter.quarter is not null
    2426   
    2527    join(
    26     select distinct f.firm_name, extract(quarter from r.reservation_date) as quarter
    27     from firm as f
    28     join auditorium as a on a.firm_id = f.firm_id
    29     join gives as g on g.auditorium_id = a.auditorium_id
    30     join movieprojection as mp on mp.projection_id = g.projection_id
    31     join reservation as r on r.projection_id = mp.projection_id
    32    
    33     ) as tabelaQuarter on tabelaQuarter.firm_name = f.firm_name
    34    
    35     join(
    36     select distinct f.firm_id,f.firm_name , a.auditorium_name as sala,sum(mp.projection_price) ,count(distinct r.reservation_id ),mp.projection_price
     28    select distinct(f2.firm_id) as firma, count(distinct r.reservation_id) as broj_kupeni,sum(mp.projection_price) as sum
    3729    from reservation as r
    38     join movieprojection as mp on mp.projection_id = r.projection_id
    39     join gives as g on g.projection_id = mp.projection_id
    40     join auditorium as a on a.auditorium_id = g.auditorium_id
    41     join firm as f on f.firm_id = a.firm_id
    42     group by 1,2,3,6
    43     order by sum desc
    44     ) as tabelaSuma on tabelaSuma.firm_id = f.firm_id
     30    left join movieprojection as mp on mp.projection_id = r.projection_id
     31    left join gives as g on g.projection_id = mp.projection_id
     32    left join auditorium as a on a.auditorium_id = g.auditorium_id
     33    left join firm as f2 on f2.firm_id = a.firm_id
     34    group by f2.firm_id
     35    ) as tabelaSuma on tabelaSuma.firma = f.firm_id
    4536    where ((extract(year from now())::integer-1)=(extract(year from r.reservation_date)::integer))
     37    group by f.firm_id,tabelaQuarter.quarter,tabelaSuma.broj_kupeni,tabelaSuma.sum
     38    order by f.firm_id
    4639}}}
    4740