application.processMessages;
select t1.some_field,
(select t2.value
from otherTable t2
where t2.name = t1.name
order by t2.value
limit 2, 1) as second_value,
(select sum(t2.value)
from otherTable t2
where t2.name = t1.name) as total_value
from table_1 t1