replace postgres command with sql equivalent