Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

displaying Columns through select Expand / Collapse
Author
Message
Posted Wednesday, June 12, 2013 11:26 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Wednesday, September 10, 2014 2:56 PM
Points: 160, Visits: 502
I have three tables
A ID, A.name, A.LastName
B ID, B.Name,B.someothername
C ID, C.why,C.whyalso

all connected by ID's

i have a query as below to get the data

select A.Name,B.name,C.Why
where A.ID = B.ID
and C.ID = A.ID

however i need the select in a way that if there are null values we show them as A.name is null or b.name is null i.e if A.name is null select A.Name as "A'S is NULL"
how do i implement this logic in a select statement

thanks
Post #1462751
Posted Wednesday, June 12, 2013 11:57 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Yesterday @ 2:54 PM
Points: 13,471, Visits: 12,329
Like this?

select isnull(A.Name, 'A is null') as AName, isnull(B.name, 'B is null') as BName, C.Why
where A.ID = B.ID
and C.ID = A.ID



_______________________________________________________________

Need help? Help us help you.

Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

Need to split a string? Try Jeff Moden's splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Post #1462766
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse