the best teacher is practice -- answer as many questions on database forums as you can
or, if you can't answer them (or can't answer them in time before someone else does), you should at least attempt them, and this means setting up the scenario, if you can, on your own database and trying to write the sql on your own
Code:
select sec_to_time(
sum(
unix_timestamp(dt_event_diffused)
-unix_timestamp(dt_event_initiated)
) ) as total_allevents
, 100 *
sum(
unix_timestamp(dt_event_diffused)
-unix_timestamp(dt_event_initiated)
)
/ ( unix_timestamp('startdate')
-unix_timestamp(date_add('enddate'
, interval 1 day))
as event_duration_percentage
from tbl_dt_event
where dt_downtime_planned = 'yesorno'
and dt_event_initiated >= 'startdate'
and dt_event_initiated < date_add('enddate'
, interval 1 day)
on a scale of 1 to 10, this one was maybe a 5
but then, i've been writing sql for about 18 years
