I'm using the following query:
select a.idclientecrm, max(c.falta) from clientescrmporlistadeclientescrm a
inner join clientescrmporlistadeclientescrm b on (a.idclientecrm=b.idclientecrm and a.idlistadeclientescrm = 58)
inner join tareas c on a.idclientecrm=c.idclientecrm
where b.idlistadeclientescrm = 70
But I'm not getting the result I want. I know I'm doing something wrong but I don't know what.
I want the outcome of the first inner join (aprox 22k rows) but I need to join the result to the "tareas" table and get the max date from there.
I want to use max because for every idclientecrm, there's more than one row that matches in the "tareas" table and I need the last recorded result.
If I left out something let me know.
Thnx in advance!