modified sql query