Concatenate fields

From: Amanda Riera <amanda(at)labtie(dot)mmt(dot)upc(dot)es>
To: pgsql <pgsql-sql(at)postgresql(dot)org>
Subject: Concatenate fields
Date: 2001-04-11 11:31:05
Message-ID: 3AD44079.FCFE4583@labtie.mmt.upc.es
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql


Hi all,
using PgSQL 7.0.3

I would like concatenate some fields to have all information in just
one field. I'm doing this below:

CREATE TABLE bill_2col AS
SELECT bill.bill_id,
(trim(text(bill.bill_number)) || ' | ' ||
trim(text(provider.company)) || ' | ' ||
trim(to_char(bill.issue_date,'MM/DD/YY')) || ' | ' ||
trim(to_char(bill.amount,'9999999.99')) || ' pts') AS billdesc
FROM bill, provider
WHERE bill.provider_id = provider.provider_id
ORDER BY bill.bill_id;

When it finds some empty field, it makes all the new field empty, no
matters
if the other are empty or not.

Here you have the result table

bill_id | billdesc
---------+---------------------------------------------------------------

0 | Unknown | Unknown | 01/01/00 | .00 pts
1 | 98018097 | SUMI Informática | 12/22/99 | 1823520.00 pts
2 |
3 | 99018089 | PISTA CERO S.L | 12/01/99 | 1949380.00 pts
4 | 99018089 | DataSystem Informática | 12/01/99 | 1949380.00 pts

5 |
6 |

Browse pgsql-sql by date

  From Date Subject
Next Message Oliver Elphick 2001-04-11 11:59:35 Re: problem with copy command
Previous Message Hans-Jürgen Schönig 2001-04-11 10:09:36 Savepoints