Genius solution
\n# Code\n\n/* Write your T-SQL query statement below */\nSELECT \n    machine_id,\n    CAST(SUM\n        (IIF(activity_type = \'end\', \n                timest
\n# Code\n```\n/* Write your T-SQL query statement below */\nSELECT \n    machine_id,\n    CAST(SUM\n        (IIF(activity_type = \'end\', \n                timestamp,\n                 -1 * (timestamp))\n        )/\n    (COUNT(timestamp) / 2) AS numeric (10,3)) AS processing_time\nFROM Activity\n\nGROUP BY machine_id\n```
['MS SQL Server']