reducer for join query