Solved

Display literal if field exists

Posted on 2008-06-24
2
216 Views
Last Modified: 2010-04-21
Hi

I have a sql statement

select HouseNumber, Street, apartment,  HouseNumber+' '+Street='  '+apartment  as FullAddress from streetable

I want to be able to display the word ' Apartment ' in they have an apartment else just display the housenumer and street

thanks chuck
0
Comment
Question by:charlesbaldo
2 Comments
 
LVL 12

Accepted Solution

by:
jgv earned 500 total points
ID: 21861881
select HouseNumber, Street, apartment,  CASE WHEN LEN(apartment) > 0 THEN 'Apartment' ELSE HouseNumber + ' ' + Street END As FullAddress from streetable
0
 

Author Closing Comment

by:charlesbaldo
ID: 31470426
Perfect, Thansk for the quick response
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Viewers will learn how the fundamental information of how to create a table.

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now