PostgreSQL Solution (Without JOIN)
Intuition\nYou can do without JOIN to solve this problem.\n\n# Code\n\nSELECT\n    machine_id,\n    ROUND(\n        CAST (\n            SUM(CASE WHEN activity_t
# Intuition\nYou can do without JOIN to solve this problem.\n\n# Code\n```\nSELECT\n    machine_id,\n    ROUND(\n        CAST (\n            SUM(CASE WHEN activity_type = \'end\' THEN timestamp ELSE -timestamp END) \n            / COUNT(DISTINCT process_id) AS numeric),\n        3\n    ) AS processing_time\nFROM Activity\nGROUP BY machine_id\n```
['Database', 'PostgreSQL']