Когда пытаюсь суммировать значения expense и income, где сравниваются id пользователя получаю дубликаты. Как можно изменить запрос, чтобы не получить дубликатов?
$people_table_data = DB::select('
SELECT people.id,
expense.people_id AS exp_p_id,
income.people_id AS inc_p_id,
people.name,
sum(expense.amount) AS exp_amount,
sum(income.amount) AS inc_amount
FROM people, expense, income
WHERE expense.people_id = people.id AND income.people_id = people.id
GROUP BY people.name, expense.people_id, income.people_id, people.id')