correct final sql - was erroneously excluding rows it shouldn't have