Fixed a bug in sql query