サブクエリが必要かどうかわかりません...
SELECT AVG(TIME_TO_SEC(y.creation_time)-TIME_TO_SEC(x.creation_time)) avg_diff
FROM my_table x
JOIN my_table y
ON y.operation_id = x.operation_id
AND y.operation_type = 'end'
WHERE x.operation_type = 'start';
サブクエリが必要かどうかわかりません...
SELECT AVG(TIME_TO_SEC(y.creation_time)-TIME_TO_SEC(x.creation_time)) avg_diff
FROM my_table x
JOIN my_table y
ON y.operation_id = x.operation_id
AND y.operation_type = 'end'
WHERE x.operation_type = 'start';