Grouping will save you:
SELECT s_n_name, COUNT(*) n, SEC_TO_TIME(SUM(TIME_TO_SEC(duration))) as t FROM _table WHERE s_n IN('001111', '002222') GROUP BY s_n;
For debugging I used the following temporary table:
CREATE TEMPORARY TABLE _table(s_n char(6), s_n_name char(14), duration TIME) SELECT '001111' s_n, 'name is 001111' s_n_name, '00:11:11' duration UNION ALL SELECT '001111' s_n, 'name is 001111' s_n_name, '00:11:11' duration UNION ALL SELECT '001111' s_n, 'name is 001111' s_n_name, '00:11:11' duration UNION ALL SELECT '002222' s_n, 'name is 002222' s_n_name, '00:22:22' duration UNION ALL SELECT '002222' s_n, 'name is 002222' s_n_name, '00:22:22' duration UNION ALL SELECT '002222' s_n, 'name is 002222' s_n_name, '00:22:22' duration UNION ALL SELECT '002222' s_n, 'name is 002222' s_n_name, '00:22:22' duration UNION ALL SELECT '003333' s_n, 'name is 003333' s_n_name, '00:33:33' duration UNION ALL SELECT '003333' s_n, 'name is 003333' s_n_name, '00:33:33' duration;
You can use the union (I did not understand that it does not work for you there), but this is hell!
SELECT s_n_name, COUNT(*) n, SEC_TO_TIME(SUM(TIME_TO_SEC(duration))) as t FROM _table WHERE s_n = '001111' UNION SELECT s_n_name, COUNT(*) n, SEC_TO_TIME(SUM(TIME_TO_SEC(duration))) as t FROM _table WHERE s_n = '002222';
where s_n='001111' OR s_n='002222'? - Alexey Shimansky