Fix a bug in the SQL query (#109)