SQL v Javascript

Suppose I run a query that retrieves all unpaid invoices owed to my company. Now, I want to get the total of those invoices. Which is more efficient / performant? Run a GROUP BY SQL query or do a JS .reduce on the original query's data? Does anyone know if there is a clear winner overall, even though certain tasks might be faster one way and other tasks faster the other way?

It would be more practical to calculate the sum with lodash's sumBy method rather than running a second query just to get the total.

@haj, the mysql sum would be the quickest as it runs on your first query. But it would only give you the total value, not the separate records.