.
Adjust sql query to work with postgresql'