sql queries complete for db