Fixed issue #1241 about SQL intersect function