Leetcode SQL

1661. Average Time of Process per Machine

Solution:

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;

Link

--

--

--

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

Recommended from Medium

Series 2: Using Fastlane to automate In-House and App Store distribution process.

Basic knowledge about Redis

The Best Way To Learn Python & Programming For A True Beginner

Accelerate. My notes and takeaways

Sourcerer negativity

Auto DevOps with GitLab CI and Docker-Compose

Check whether two strings are anagram of each other or not

How to download Images using Python & Google Colab?

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
Isabelle

Isabelle

In love with telling stories with data

More from Medium

Leetcode SQL

LeetCode SQL| 196. Delete Duplicate Emails

SQL Server Join Algorithms — and how to benefit from knowing them

Essential SQL and NONSQL concepts in software development