PROBLEM : I must select NAROCILO.ŠIFRA.NAROCILA, VREDNOST (which is ŠTEVILO_NAROCENIH* PRODAJNA_CENA in POSTAVKA_NAROCILA) and give result. But in POSTAVKA_NAROCILA there are 4 same values of ŠIFRA_NAROCILA (12491 and 12498) and their result of VREDNOST must be SUM-ed in final result for NAROCILO.ŠIFRA_NAROCILA. In other words, there should be 7 final results for VREDNOST and NAROCILO.ŠIFRA.NAROCILA (same as in table NAROCILO).

SELECT a.ŠIFRA_NAROCILA,
SUM(b.ŠTEVILO_NAROCENIH * b.PRODAJNA_CENA) AS vrednost
FROM dbo.NAROCILO AS a
INNER JOIN dbo.POSTAVKA_NAROCILA AS b ON b.šifra_narocila = a.šifra_narocila
GROUP BY a.šifra_narocila
ORDER BY a.šifra_narocila DESC;

SELECT a.ŠIFRA_NAROCILA,
SUM(b.ŠTEVILO_NAROCENIH * b.PRODAJNA_CENA) AS vrednost
FROM dbo.NAROCILO AS a
INNER JOIN dbo.POSTAVKA_NAROCILA AS b ON b.šifra_narocila = a.šifra_narocila
GROUP BY a.šifra_narocila
ORDER BY a.šifra_narocila DESC;