Hello,
You need the last execution of each process, right? Below is a query that solves 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 doubt we’re there, good luck!
What is the database manager (and version): Oracle Database? Mariadb? Postgresql? SQL Server?
– José Diz