CREATE OR REPLACE VIEW food600.semafory_zapnute
 AS
 SELECT spodny.i_semafor,
    spodny.n_semafor,
    spodny.kto,
    spodny.kedy,
    spodny.zapnuty
   FROM ( SELECT semafor.i_semafor,
            semafor.n_semafor,
            semafor.kto,
            semafor.kedy,
            length(btrim(food600.semafor_stav(semafor.n_semafor::bpchar)::text)) AS zapnuty
           FROM food600.semafor
          ORDER BY semafor.kedy) spodny
  WHERE spodny.zapnuty > 0;
