select allocation.ID, allocation.ARTICLE_ID, sum(wstock.ATP) as atp
from allocation allocation
join ARTICLE article on allocation.ARTICLE_ID = article.ID
join WAREHOUSE_STOCK wstock on article.ID = wstock.article_id
group by allocation.ID, allocation.ARTICLE_ID;