change sql to pg