SQL query corrections and testing get