Fixed a logical ordering problem

Alternative on query parameters wasn't being applied first which
occasionally led to problems if 'alternate' ID could be coerced to the
same type as the ID column and retrieve the wrong record.