CREATE VIEW stan_zapasow AS SELECT t.kod, t.nazwa, sum(z.ilosc) AS STAN FROM towary t JOIN zasoby z ON t.id=z.towar GROUP BY t.nazwa, t.kod;