sql fix for postgre