Removed 'ORDER BY' in sql query. It was causing problems with SDE data.