from test
-> ;
+----+----------+-------------+
| id | status | instance_id |
+----+----------+-------------+
| 1 | COMPLETE | 1 |
| 2 | RUNNING | 1 |
| 3 | CANCEL | 1 |
| 4 | COMPLETE | 2 |
| 5 | COMPLETE | 2 |
| 6 | RUNNING | 2 |
+----+----------+-------------+
that shows execution status of tasks on 3 servers
and i needed to make the report
if there is cancel -> then task is canceled
else if there is running -> then task is yet running
else it is compled
I know that I can do this with digits - for example for status I make another table with statuses
id | status
1| COMPLETED
2| RUNNING
3| CANCELED
and choose the max
select instance_id, max(status) from test group by instance_id;
BUT how I can do this only with literals, without additional table?
use enums
Обсуждают сегодня