you have two queries that could potentially be comparing more than one row to a single value;
one is a simple test for a value:
if (select UNITE_COUT_MATERIEL from DIM_INTER_MATERIEL) = 'Unité'
begin
end
and the other is assigning a calculation to a variable.
set @DU_QTE = (select (SUPERFICIE_INTER_CULTURE / SUPERFICIE_INTER) * QUANTITE_MATERIEL from FACT_INTERVENTION inter,DIM_INTER_MATERIEL mat
where inter.ID_INTER=mat.ID_INTER )
So the issue is if multiple rows exist, what calculation do you really want? would the sum() work where there are multiple rows? don't you need to filter the calculation as well?
I would consider changing it to something like this:
--is there ANY data which matches this criteria?
if EXISTS (select 1 from DIM_INTER_MATERIEL WHERE UNITE_COUT_MATERIEL = 'Unité')
begin
select @DU_QTE = (SUM(SUPERFICIE_INTER_CULTURE) / SUM(SUPERFICIE_INTER)) * SUM(QUANTITE_MATERIEL)
from FACT_INTERVENTION inter
INNER JOIN DIM_INTER_MATERIEL mat
ON inter.ID_INTER=mat.ID_INTER
WHERE UNITE_COUT_MATERIEL = 'Unité'
print cast(@DU_QTE as varchar (50));
end
Lowell