SQL: Fixed bug on LET when indexes were used