user3510431
user3510431

Reputation: 55

MySql - Create sum from main and second table

I have two tables in MySql:

  1. main:

and_fakture field:id, organizatorId,...

  1. second: and_stavke field:id,idFakture,ukupno,... where and_fakture.id=and_stavke.idFakture

ukupno is numeric

How can i sum(ukupno) from organizatorId ?

Upvotes: 0

Views: 24

Answers (1)

Sal00m
Sal00m

Reputation: 2916

Your question is not very clear, but you want something like this?:

SELECT organizatorId, SUM(ukupno) 
FROM and_fakture
INNER JOIN and_stavke ON and_fakture.id = and_stavke.idFakture
GROUP BY organizatorId

This will give you the sum of ukupno by every organizatorId

Upvotes: 1

Related Questions