i have 2 select statements, 1 for getting the latest failed status and one for getting the latest missed status. in the 3rd i need to have a statement if the latest status is with missed or failed but it seems to have merged the data? im using LIKE because the missed and failed may vary slightly
mysql> select max(scheduled_start),node_name,schedule_name,status from `events_server` WHERE status LIKE '%Failed%'and node_name='name';
+----------------------+----------------+---------------+-----------+
| max(scheduled_start) | node_name | schedule_name | status |
+----------------------+----------------+---------------+-----------+
| 2013-01-30 15:00:00 | name | name_1500 | Failed 1 |
+----------------------+----------------+---------------+-----------+
1 row in set (0.01 sec)
mysql> select max(scheduled_start),node_name,schedule_name,status from `events_server` WHERE status LIKE '%Missed%'and node_name='name';
+----------------------+----------------+---------------+--------+
| max(scheduled_start) | node_name | schedule_name | status |
+----------------------+----------------+---------------+--------+
| 2013-01-23 08:00:00 | name | NAME_0800 | Missed |
+----------------------+----------------+---------------+--------+
1 row in set (0.01 sec)
mysql> select max(scheduled_start),node_name,schedule_name,status from `events_server` WHERE (status LIKE '%Failed%' OR status LIKE '%Missed%') and node_na
me='name';
+----------------------+----------------+---------------+--------+
| max(scheduled_start) | node_name | schedule_name | status |
+----------------------+----------------+---------------+--------+
| 2013-01-30 15:00:00 | name | NAME_0800 | Missed |
+----------------------+----------------+---------------+--------+
1 row in set (0.01 sec)
Have you tried something similar to this which will pivot the data and return a separate column for each status. This will give you the
max(scheduled_start)for both theFailedandMissedstatuses. But you also need to add aGROUP BYto get the result: