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 |
| 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 |
29 | | group by li_ime, interval_1h |
30 | | order by li_ime, interval_1h |
| 32 | where broj_pati = ( |
| 33 | select max(broj_pati) |
| 34 | from( |
| 35 | select li_ime, interval_1h , count(li_ime||'-'||interval_1h) broj_pati |
| 36 | from( |
| 37 | select *, |
| 38 | (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 |
| 39 | from project.linija li |
| 40 | left join project.instancanalinija inl on li.li_id = inl.li_id |
| 41 | left join project.vozenje v on inl.inl_id = v.inl_id |
| 42 | where li_ime = li_ime_given |
| 43 | ) |
| 44 | group by li_ime, interval_1h |
| 45 | order by li_ime, interval_1h |
| 46 | ) |
| 47 | group by li_ime |
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) |