Changes between Version 15 and Version 16 of AdvancedReports


Ignore:
Timestamp:
01/26/22 01:29:14 (3 years ago)
Author:
183060
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • AdvancedReports

    v15 v16  
    9090        where extract (year from p.vreme) = extract (year from current_date)
    9191        group by 1, 2
    92 ) upati_quarter on (o.oddel_id, o.bolnica_id) = (upati_quarter.oddel_id, upati_quarter.bolnica_id)
     92) upati_quarter on (o.oddel_id, o.bolnica_id) = (upati_quarter.oddel_id, upati_quarter.bolnica_id) ;
     93}}}
     94
     95
     96
     97== Тренд на препишани лекови по тримесечја за тековната година
     98
     99{{{#!sql
     100select distinct l.ime_lek,
     101        case when recepta_quarter.trimesecje = 1 then recepti_za_lekovi.recepti_za_lek else 0 end as quarter_1_recepti_za_lek,
     102        case when recepta_quarter.trimesecje = 2 then recepti_za_lekovi.recepti_za_lek else 0 end as quarter_2_recepti_za_lek,
     103        case when recepta_quarter.trimesecje = 3 then recepti_za_lekovi.recepti_za_lek else 0 end as quarter_3_recepti_za_lek,
     104        case when recepta_quarter.trimesecje = 4 then recepti_za_lekovi.recepti_za_lek else 0 end as quarter_4_recepti_za_lek
     105from recepta r
     106join lekovi l on r.lek_id = l.lek_id
     107join (
     108        select r.recepta_id, extract (quarter from r.datum_izdavanje) as trimesecje
     109        from recepta r
     110) recepta_quarter on r.recepta_id = recepta_quarter.recepta_id
     111join (
     112        select r.lek_id, count(r.recepta_id) as recepti_za_lek
     113        from recepta r
     114        where extract (year from r.datum_izdavanje) = extract (year from current_date)
     115        group by 1
     116) recepti_za_lekovi on r.lek_id = recepti_za_lekovi.lek_id
     117order by 2 desc, 3 desc, 4 desc, 5 desc ;
    93118}}}
    94119