SQL SERVER - INNER JOIN - ROUND - AVG built in
\n# Code\n\nSELECT a.machine_id, ROUND(AVG(b.timestamp-a.timestamp),3) as processing_time\nFROM Activity a\nINNER JOIN Activity b\nON a.machine_id=b.machine_id 
\n# Code\n```\nSELECT a.machine_id, ROUND(AVG(b.timestamp-a.timestamp),3) as processing_time\nFROM Activity a\nINNER JOIN Activity b\nON a.machine_id=b.machine_id and a.process_id=b.process_id and a.activity_type=\'start\' and b.activity_type=\'end\'\nGROUP BY a.machine_id\n```
['MS SQL Server']