CREATE OR REPLACE VIEW food600.skashor_set
 AS
 SELECT hor_set.rastr,
    hor_set.kdy,
    hor_set.kdo,
    hor_set.rastr1,
    hor_set.rastr2,
    hor_set.rastr3,
    hor_set.rastr4,
    hor_set.rastr5,
    hor_set.rastr6,
    hor_set.rastr7,
    hor_set.rastr8,
    hor_set.rastr9,
    hor_set.c_druh,
    hor_set.id,
    skupiny.druh::character(30)
   FROM food600.hor_set
     LEFT JOIN food600.skupiny ON hor_set.c_druh = skupiny.c_druh AND hor_set.c_data = skupiny.c_data
  WHERE hor_set.c_druh <> '-1'::integer AND hor_set.c_druh <> 0
UNION
 SELECT hor_set.rastr,
    hor_set.kdy,
    hor_set.kdo,
    hor_set.rastr1,
    hor_set.rastr2,
    hor_set.rastr3,
    hor_set.rastr4,
    hor_set.rastr5,
    hor_set.rastr6,
    hor_set.rastr7,
    hor_set.rastr8,
    hor_set.rastr9,
    hor_set.c_druh,
    hor_set.id,
    'TIP'::character(30) AS druh
   FROM food600.hor_set
  WHERE hor_set.c_druh = '-1'::integer;
