Improved qb with advanced join conditions