| 15 | {{{#!div style="font-size: 80%" |
| 16 | {{{#!sql |
| 17 | |
| 18 | |
| 19 | select li_ime_given as li_ime, interval_1h , broj_pati |
| 20 | from( |
| 21 | select li_ime as li_ime_given, interval_1h , count(li_ime||'-'||interval_1h) broj_pati |
| 22 | from( |
| 23 | select *, |
| 24 | (to_char(extract (hour from vozenje_start), '00') || ':00 -' || to_char(extract (hour from (vozenje_start + '1 hours'::interval))::int, '00') || ':00') as interval_1h |
| 25 | from project.linija li |
| 26 | left join project.instancanalinija inl on li.li_id = inl.li_id |
| 27 | left join project.vozenje v on inl.inl_id = v.inl_id |
| 28 | ) |
| 29 | group by li_ime, interval_1h |
| 30 | order by li_ime, interval_1h |
| 31 | ) |
| 32 | where broj_pati = (select max(broj_pati) |
| 33 | from |
| 34 | (select li_ime, interval_1h , count(li_ime||'-'||interval_1h) broj_pati |
| 35 | from( |
| 36 | select *, |
| 37 | (to_char(extract (hour from vozenje_start), '00') || ':00 -' || to_char(extract (hour from (vozenje_start + '1 hours'::interval))::int, '00') || ':00') as interval_1h |
| 38 | from project.linija li |
| 39 | left join project.instancanalinija inl on li.li_id = inl.li_id |
| 40 | left join project.vozenje v on inl.inl_id = v.inl_id |
| 41 | where li_ime = li_ime_given |
| 42 | ) |
| 43 | group by li_ime, interval_1h |
| 44 | order by li_ime, interval_1h ) |
| 45 | group by li_ime) |
| 46 | |
| 47 | |
| 48 | }}} |
| 49 | }}} |
| 50 | |