CREATE OR REPLACE VIEW food600.sspotrebapouzavierkach
 AS
 SELECT food_dat.id_zkratka AS sklad,
    sum(sk__pol.mnozstvi) AS mnozstvi,
    sum(sk__pol.prachy) AS cena,
    sk__pol.cen_hlad,
    "substring"(karty.nazev::text, 1, 27) AS nazev,
    "substring"(karty.nazev::text, 28, 3) AS mj,
    skupiny.druh,
    sk__uza.uzaverka,
    sk__uza.id_kas
   FROM food600.sk__pol
     JOIN food600.sk__uza ON sk__pol.c_uzaverka = sk__uza.idriadok
     JOIN food600.karty ON sk__pol.c_karty = karty.c_karty
     LEFT JOIN food600.skupiny ON karty.c_druhk = skupiny.c_druh
     LEFT JOIN food600.food_dat ON sk__pol.c_stredisk = food_dat.c_stredisk
  WHERE sk__pol.c_uzaverka > 0
  GROUP BY sk__uza.id_kas, sk__uza.uzaverka, sk__pol.cen_hlad, food_dat.id_zkratka, karty.nazev, skupiny.druh
  ORDER BY sk__uza.id_kas, sk__uza.uzaverka;
