Hello,
You need the last run of each process, right? Here is a query that resolves this scenario.
select distinct nome_processo,
(select max(data)
from processos p2
where p1.nome_processo = p2.nome_processo) as ULTIMA_EXECUCAO
from processos p1;
Data example:
+----+---------------+-----------------+------------+
| id | nome_processo | status_processo | data |
+----+---------------+-----------------+------------+
| 1 | RPA_001 | sucesso | 2018-10-03 |
| 2 | RPA_002 | sucesso | 2018-10-04 |
| 3 | RPA_003 | erro | 2018-10-05 |
| 4 | RPA_003 | sucesso | 2018-10-04 |
| 5 | RPA_001 | sucesso | 2018-10-04 |
| 6 | RPA_002 | sucesso | 2018-10-06 |
+----+---------------+-----------------+------------+
Query return:
+---------------+------------+---+
| nome_processo | ULTIMA_EXECUCAO|
+---------------+----------------+
| RPA_001 | 2018-10-04 |
| RPA_002 | 2018-10-06 |
| RPA_003 | 2018-10-05 |
+---------------+----------------+
Any questions are there, good luck!