Fix syntax error in orders query

If the list of unscheduled projects is empty, the restriction shouldn't be added
or it'll cause a syntax error due to an empty list "o.id IN ()".

FEA: ItEr77S15FilteringEnhancements