Solved

tsql NULL record not showing with CASE

Posted on 2013-12-16
4
277 Views
Last Modified: 2013-12-16
My query is not showing my NULL values.  What am I missing?  Thanks!

SELECT        AccessList.ALMYID, AccessList.FirstName, AccessList.LastName, AccessList.ClassStanding, Seminars.SeminarDetails, AccessList.TermGPA, 
                         AccessList.MYCompletedCredits, StudentSeminars.SHasAttended, StudentSeminars.SSeminarID, AccessList.CumulativeGPA, AccessList.CompletedCredits, 
                         AccessList.IsTransfer, Demographics.DEmail, 
						 CASE WHEN (StudentSignature.SSigID IS NULL) 
						 THEN 'No'
						 ELSE 'Yes'
						 END AS Signed
FROM            AccessList INNER JOIN
                         StudentSeminars ON AccessList.ALMYID = StudentSeminars.SMYID INNER JOIN
                         Seminars ON StudentSeminars.SSeminarSelected = Seminars.SeminarID INNER JOIN
                         Demographics ON StudentSeminars.SMYID = Demographics.DMYID INNER JOIN
                         StudentSignature ON StudentSeminars.SMYID = StudentSignature.SSMYID
WHERE (Seminars.SeminarID = @SeminarID)

Open in new window

0
Comment
Question by:javierpdx
4 Comments
 
LVL 21

Accepted Solution

by:
Dale Burrell earned 400 total points
ID: 39723023
What values are null? And how do you know?

Best guess is because all your joins are inner joins which means that any rows joined on null will mean the entire row doesn't show. You need to use left joins if you want to see null values.
0
 
LVL 10

Expert Comment

by:HuaMinChen
ID: 39723078
Put a relevant value for Null column, like
isnull(col1,'')

Open in new window

0
 
LVL 13

Assisted Solution

by:magarity
magarity earned 100 total points
ID: 39723212
If there is no corresponding record at all in the StudentSignature table then you need to use LEFT OUTER JOIN for it instead of INNER JOIN.  This is what I suspect since your CASE statement is phrased correctly for NULL in that field.
0
 

Author Closing Comment

by:javierpdx
ID: 39723253
Thanks. With LEFT JOIN, the No value did show as "No".
0

Featured Post

Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

Question has a verified solution.

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

For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Via a live example, show how to shrink a transaction log file down to a reasonable size.

911 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

22 Experts available now in Live!

Get 1:1 Help Now