try to fix postgres sql statement