1661. 'Average Time of Process per Machine' | SQL 50 | Leetcode | SQL Interview | Self join | CTE

preview_player
Показать описание
SQL interview preparation. CTE explained.
CTEs can be used multiple times within the same query, simplifying complex queries and improving query performance. By breaking up queries into smaller, logical pieces, SQL CTEs can also enhance readability, making code easier to understand and maintain.
My solution to this question "Beats 100.00%of users with MS SQL Server"

Do let me know if you would like me to make a video that covers any particular SQL concept. And please share your feedback in the comment section.

There is a factory website that has several machines each running the same number of processes. Write a solution to find the average time each machine takes to complete a process.

The time to complete a process is the 'end' timestamp minus the 'start' timestamp. The average time is calculated by the total time to complete every process on the machine divided by the number of processes that were run.

The resulting table should have the machine_id along with the average time as processing_time, which should be rounded to 3 decimal places.

Return the result table in any order.
Рекомендации по теме