Improved SQL Test