MySql Solution || No join || No subquery
Mysql Solution :-\n Since we have to find processing_time for each machine hence --\n group by machine_id\n Now by using avg() function we are calculating avera
# Mysql Solution :-\n* Since we have to find processing_time for each machine hence --\n group by machine_id\n* Now by using avg() function we are calculating average of total time \n* but before calculating avg funtion we are mapping each timestamp value to either **positive value** or **negative value**, depending on whether it is start time or end time. If it is start time then mapping it to negative value otherwise positive value.\n* Since avg is calculated as ->\n\tavg = (sum of all elements) divided by (number of elements) i.e sum / count\n* In the calculation of avg, start time and end time both will be considered two different elements hence total sum of start time and end time will be divided by **twice the number of actual processes** hence at last we are multiplying the average by two. For better understanding have a look on calculation done below->\n\n# Calculation Part :-\n1. average  = total sum / number of elements\n2. Here "st" represents start time and "et" represents end time.\n3. total sum = ( -st1 + et1 - st2 + et2 -st3 + et3 ....)\n4. For each process_id there will be two element count, one for start time and one for end time. For example if there are 3 different processes then average will be calculated as ----\n\t\tavg = (-st1 + et1 - st2 + et2 - st3 + et3) / ( 6 )\n5. To correct this average we will have to multiply whole average value by two i.e. ->\n\t  ==>> avg = 2 * (-st1 + et1 - st2 + et2 - st3 + et3) / ( 6 )\n\t  ==>> avg = (-st1 + et1 - st2 + et2 - st3 + et3) / ( 3 )\n\t  \n# Query Part :- \n\n` select machine_id, Round(2 * avg(if(activity_type = \'start\',-timestamp, timestamp)),3) as processing_time\n\t   from  activity \n\t   group by machine_id`
['MySQL']