[#514] Do not use postgres concat function. Use || instead.
Concat is not supported in pg 9.0. The || syntax howver does not allow  null as one argument. So we use coalesce to either get the value or an empty string.
Use substr instead of left, so it works on Postgres < 9.1