Usa una query que envuelva tu sentencia actual, la que pasaría a ser una subconsulta. Refactorizando tu código actual, hoy tienes: const sentencia_union = ` SELECT sum(Amount) AS total FROM debts_credit_card WHERE username = ? BETWEEN ? AND ? UNION SELECT SUM(Amount) AS TOTAL FROM debts_loan WHERE username = ? BETWEEN ? AND ? `; const debts1 = await pool.query( sentencia_union , [ username,date,date2,username,date,date2 ] ); Y quedaría, en cambio: const sentencia_union = ` SELECT sum(Amount) AS total FROM debts_credit_card WHERE username = ? BETWEEN ? AND ? UNION SELECT SUM(Amount) AS TOTAL FROM debts_loan WHERE username = ? BETWEEN ? AND ? `; const queryPrincipal = ` SELECT sum(total) as gran_total FROM (${sentencia_union}) as subquery`; // importante! ponerle nombre const debts1 = await pool.query( queryPrincipal , [ username,date,date2,username,date,date2 ] ); Sólo procura ponerle un alias porque sino MySQL devolverá el error: "`every derived table must have its alias`" o algo así. (Parto de la base que no vas a traer más columnas, así que no me preucuparé de la cláusula GROUP BY )