there is always one very good way to determine if a query is
correct or not
test it and see what happens
often, this will tell you right away if it is incorrect, if it returns something that you know is wrong
if, on the other hand, it appears to work correctly, then your task is to test it on increasingly robust and comprehensive data samples, up to and including full volume, live data
so, what happened when you tested it?
