Solved

Display literal if field exists

Posted on 2008-06-24
2
243 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:Charles Baldo
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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:Charles Baldo
ID: 31470426
Perfect, Thansk for the quick response
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Suggested Solutions

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

732 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