replace sql to pg