I've constructed the below query which satisfies the requirements, except output includes NULL values between all "vendor_address2" columns, which isn't intended. I suspect my error is somewhere within the WHERE
clause, which is designed to exclude any NULL values in the resulting output. I've included a copy of the corresponding table below the output for my most recent query:
SELECT vendor_name,
vendor_address1 || ' ' || vendor_address2 || ' ' || vendor_city || ', ' || vendor_state || ' ' || vendor_zip_code AS "Complete Address"
FROM ap.vendors
WHERE (vendor_address1 || vendor_address2 || vendor_city || vendor_state || vendor_zip_code) IS NOT NULL
ORDER BY vendor_name;
The resulting output:
Here is the corresponding table-view:
Thank you.
Best Answer
The screenshot of your data and output clearly shows the problem. The concatenation operator automatically takes care of
NULL
and you don't need to do anyhting. But you don't haveNULL
in your tables, you have'NULL'
, a string, in your tables.If you really had
NULL
in your table, SQL Developer would display(null)
in the data grid.Clean your data, then try again.
Alternatively, you can turn string
'NULL'
to a realNULL
on the fly:But don't do that. Take care of your data.