I am running into an issue when adding data from multiple columns into
one alias:
P.ADDR1 + ' - ' + P.CITY + ',' + ' ' + P.STATE AS LOCATION
If one of the 3 values is blank, the value LOCATION becomes NULL. How
can I inlcude any of the 3 values without LOCATION becoming NULL?
Example, if ADDR1 and CITY have values but STATE is blank, I get a
NULL statement for LOCATION. I still want it to show ADDR1 and CITY
even if STATE is blank.
Thanks 4 1788
ISNULL(P.CITY,'')
Techhead wrote:
I am running into an issue when adding data from multiple columns into
one alias:
P.ADDR1 + ' - ' + P.CITY + ',' + ' ' + P.STATE AS LOCATION
If one of the 3 values is blank, the value LOCATION becomes NULL. How
can I inlcude any of the 3 values without LOCATION becoming NULL?
Example, if ADDR1 and CITY have values but STATE is blank, I get a
NULL statement for LOCATION. I still want it to show ADDR1 and CITY
even if STATE is blank.
Thanks
You can use COALESCE, something like this will do it:
COALESCE(P.ADDR1, '') + ' - ' + COALESCE(P.CITY, '') + ', ' +
COALESCE(P.STATE, '') AS LOCATION
Also, you can play with formatting variations based on what you want to get
when one of the columns is NULL, like this:
COALESCE(P.ADDR1, '') + COALESCE(' - ' + P.CITY, '') + COALESCE(', ' +
P.STATE, '') AS LOCATION
HTH,
Plamen Ratchev http://www.SQLStudio.com
On Jun 4, 3:29 pm, "Plamen Ratchev" <Pla...@SQLStudio.comwrote:
You can use COALESCE, something like this will do it:
COALESCE(P.ADDR1, '') + ' - ' + COALESCE(P.CITY, '') + ', ' +
COALESCE(P.STATE, '') AS LOCATION
Also, you can play with formatting variations based on what you want to get
when one of the columns is NULL, like this:
COALESCE(P.ADDR1, '') + COALESCE(' - ' + P.CITY, '') + COALESCE(', ' +
P.STATE, '') AS LOCATION
HTH,
Plamen Ratchevhttp://www.SQLStudio.com
Somebody at work told me to use this:
SELECT CASE WHEN P.STATE IS NULL THEN '' ELSE P.STATE END
It seems to work. Is this similar as to what is described above? This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Steve Walker |
last post by:
Hi all.
I've been tasked with "speeding up" a mid-sized production system. It
is riddled with nulls... "IsNull" all over the procs, etc.
Is it worth it to get rid of the nulls and not allow...
|
by: Cro |
last post by:
Dear Access Developers,
The 'Allow Additions' property of my form is causing unexpected
results.
I am developing a form that has its 'Default View' property set to
'Continuous Forms' and am...
|
by: Mike |
last post by:
The current databas structure that i'm working with allowed NULL's an now
I'm converting the app to .NET and it will not allow NULLs in the fields
when populated.
So my question is, how can i...
|
by: Gary Blakely |
last post by:
I'm giving this post another try - it can't be too difficult for
everyone....
In the program below, the web page has dataGrid1. the only thing that has
been done to it at design time is to...
|
by: Edmund Dengler |
last post by:
Howdy all!
Just checking on whether this is the expected behaviour. I am transferring
data from multiple databases to single one, and I want to ensure that I
only have unique rows for some...
|
by: Martin Joergensen |
last post by:
Hi,
I have some files which has the following content:
0 0 0 0 0 0
0 1 1 1 1 0
0 1 1 1 1 0
0 1 1 1 1 0
0 1 1 1 1 0
0 0 0 0 0 0
|
by: Bob Stearns |
last post by:
I am creating an index on a column which is 40% NULLS. The process seems
to run forever, though a count of the number of values runs in
milliseconds. This leads to the subject question: is there a...
|
by: markjerz |
last post by:
Hi,
I basically have two tables with the same structure. One is an archive
of the other (backup). I want to essentially insert the data in to the
other.
I use:
INSERT INTO table ( column,...
|
by: Chris |
last post by:
I have created a datatable from a csv file. One of the columns is an integer
which sometimes can be blank. When it is blank I add a dbnull.value to the
column when I add to the datatable. This...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |