Using Common Table Expression
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```mssql []\n/* Write your T-SQL query statement below */\nWITH ste AS\n(SELECT * FROM Activity WHERE activity_type = \'start\'),\nente AS\n(SELECT * FROM Activity WHERE activity_type = \'end\')\nSELECT ste.machine_id, ROUND(AVG(ente.timestamp - ste.timestamp), 3) Processing_time FROM ste JOIN ente\nON ste.machine_id = ente.machine_id\nGROUP BY ste.machine_id\n```
['MS SQL Server']