https://lincoln-yuji.github.io/posts/case-when-inside-sql-join/
CASE/WHEN inside SQL JOIN conditions - Lincoln Yuji