15 |
rodolico |
1 |
select
|
|
|
2 |
device.name as 'Device',
|
|
|
3 |
client.name as 'Client',
|
|
|
4 |
maintenance_task.description as 'Task',
|
|
|
5 |
maintenance_schedule.schedule as schedule,
|
|
|
6 |
date_format(max(maintenance_performed.maintenance_date),'%Y-%m-%d') as 'Last Performed',
|
|
|
7 |
date_format(adddate(max(maintenance_performed.maintenance_date),maintenance_schedule.schedule),'%Y-%m-%d') as 'Next Due'
|
|
|
8 |
from
|
|
|
9 |
maintenance_schedule join maintenance_task using (maintenance_task_id)
|
|
|
10 |
join device using (device_id)
|
|
|
11 |
join maintenance_performed using (maintenance_task_id,device_id)
|
|
|
12 |
join site using (site_id)
|
|
|
13 |
join client using (client_id)
|
|
|
14 |
where
|
|
|
15 |
maintenance_schedule.removed_date is null
|
|
|
16 |
and device.removed_date is null
|
|
|
17 |
group by
|
|
|
18 |
device.name,
|
|
|
19 |
maintenance_task.description
|
|
|
20 |
order by
|
|
|
21 |
client.name,
|
|
|
22 |
device.name,
|
|
|
23 |
maintenance_task.description
|
|
|
24 |
;
|