[FIX] procurement: change SQL query to be compatible with both postgres 8.4 and 9.3