Table t1 contains a series of basic data and is unique on Id.
Table t2 contains a large amount of time series data that I need to scope down to just a subset. I am only interested in somevalue and yetanothervalue. Struggling to find the cleanest way to do that in this context.
The query below runs, but I have used MAX incorrectly. Studying mysql docs related to greatest-n-pergroup and trying to get that solved.
I am interested in the where usage and efficiencies - what is the best pattern to add those where clauses.
select t1.*,
t2.lastdate as lastdate,
from t1
left join
( select Id,
max(LastDate) as lastdate
from t2table
where
somecolumn like '%somevalue%'
group by Id
) t2
on t1.Id = t2.Id
where yetanothercolumn = "yetanothervalue";
Also - any links to docs or other threads and examples appreciated.