nested joins re-implemented to support
left join
    inner join
case