Fixes error in SQL