Fixes Bug 905346: fix cut/paste errors in query

Fix a couple errors noticed when trying to deploy on stage. Sorry about this -- difficult to spot the problems on dev.