the goal is getting the sum(account.price) for all the clients but i get duplicates values, so the sum wont be correct, thats why i use DISTINCT, whats the solution for this common problem btw DISTINCT and sum()
FROM Client, Account
WHERE Client.Accountspeed = Account.speed AND Client.Active='YES' AND Client.id NOT IN (SELECT Client_ID_Monthpayed FROM MonthPayed Where Month_Payed=Insert_Month);
it is working now, i dont know how lol, i must have changed the order of something in the sql im getting a correct sum without duplicates
FROM (SELECT DISTINCT Client.id
WHERE Client.Active='YES' AND NOT EXISTS (SELECT * FROM MonthPayed Where Month_Payed=Insert_Month AND Client.id = Client_ID_Monthpayed)) AS clients
ON Clients.Accountspeed = Account.speed
Do you really have duplicate client ids in you client table?