Leetcode SQL

1661. Average Time of Process per Machine


select machine_id, 
round((sum(case when activity_type = 'end' then timestamp end)- sum(case when activity_type = 'start' then timestamp end))
/count(distinct process_id),3) as processing_time
from Activity
group by 1;





My homepage to record my thought processes for solving SQL and Algorithm questions

Recommended from Medium

Amazon Web Services (AWS), the most widely used and comprehensive cloud platform in the world…

Engineering and Operational Excellence

Organizations looking to better locate, understand, manage and gain value from their data have a…

How to sync an entire database with Facebook

30 Days of creating with Canonic

Golang, Microservices and Twirp

Deciphering Competitive Code — Part 1 of…?

Tricks of the Trade Department: Coffee is for Closers — and Coders

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Jen-Li Chen

Jen-Li Chen

In love with telling stories with data

More from Medium

Leetcode SQL

LeetCode SQL| 196. Delete Duplicate Emails

The physical structure of an SQL index