Fix SQL - last version was actually quite amater