Fixing the last problems with SQL