The inner Select was not closing the parenthesis. Added [TX] to queries