Fixed missing select statement in queries