I have the following reference data.
PERSON_NAME STREET TOWN COUNTY POSTCODE
------------------------------ ------------------------ ---------------- ---------------- ----------
David Smith 30 Johnson Street Norwich Norfolk NA38 3KL
John Brown Douglas Road Cambridge C8 9IJ
Jackie White 8 High Street Ipswich Suffolk IP7 2YT
Andrea Blue 9 Marlborough Ave Bury Suffolk IP4 0XC
Jemima Green Riverside Walk Colchester Essex CO6 7PR
James Gray 167 Hadleigh Place London SW1 4TU
What I want to do is display a list of the names of people along with their concatenated addresses in a comma separated line.
This part is simple, I used columns ||for concat and put comma separators.
The part I doubt about is that some lines don't have anything listed for COUNTY, so I need to avoid displaying , ,.
SUBSTR Oracle , "". , ( SO)?
, :
SELECT
SUPPNAME as "Supplier Name",
REPLACE(STREET || ', ' || TOWN || ', ' || COUNTY || ', ' || POSTCODE, ' ,','') as "Supplier Address"
FROM
SUPPLIERS
;