Solved

Need results with a NULL field.

Posted on 2008-10-10
3
191 Views
Last Modified: 2008-11-15
I have a report that shows me labs my company has run for a specific time period. The labs are usually run for a surgeon but not always and thus the surgeon (tbldoctors.lastname) field is sometimes NULL. I need to get the results for a specific time period regardless of the fact that this field might be null so that we can see all labs performed. I am attaching the SQL statement created by Crystal below as a CODE SNIPPET

My results are as follows for 6/1/08 - 10/10/08
-1- If I remove the tbldoctors.lastname field, I get 20 labs for the time frame
-2- If I leave the tbldoctors.lastname field, I get 13 labs for the same time period

I tried the following formula field to try to get the NULL fields to return "n/a" but I get the same 13 results:

if isnull ({tblDoctors.LastName}) then "n/a" else
{tblDoctors.LastName}

Any help would be GREATLY APPRECIATED.
SELECT "tblCadaverLabs"."LabID", "tblLabLocations"."LocationName", "tblCadaverLabs"."LabDate", "tblMISUsers"."Name", "tblCadaverLabs"."LabStatus", "tblDoctors"."LastName"
 FROM   (((("ATR0605_003LIVE"."dbo"."tblCadaverLabs" "tblCadaverLabs" INNER JOIN "ATR0605_003LIVE"."dbo"."tblLabLocations" "tblLabLocations" ON "tblCadaverLabs"."LocationID"="tblLabLocations"."LocationID") INNER JOIN "ATR0605_003LIVE"."dbo"."tblLabSupport" "tblLabSupport" ON "tblCadaverLabs"."LabID"="tblLabSupport"."LabID") INNER JOIN "ATR0605_003LIVE"."dbo"."tblLabDoctors" "tblLabDoctors" ON "tblCadaverLabs"."LabID"="tblLabDoctors"."LabID") INNER JOIN "ATR0605_003LIVE"."dbo"."tblDoctors" "tblDoctors" ON "tblLabDoctors"."DoctorID"="tblDoctors"."DoctorID") INNER JOIN "ATR0605_003LIVE"."dbo"."tblMISUsers" "tblMISUsers" ON "tblLabSupport"."UserID"="tblMISUsers"."UserID"
 WHERE  ("tblCadaverLabs"."LabDate">={ts '2008-06-01 00:00:00'} AND "tblCadaverLabs"."LabDate"<{ts '2008-10-11 00:00:00'}) AND "tblCadaverLabs"."LabStatus"='original'
 ORDER BY "tblCadaverLabs"."LabDate"

Open in new window

0
Comment
Question by:dsabine
[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
3 Comments
 
LVL 101

Accepted Solution

by:
mlmcc earned 500 total points
ID: 22693977
Try using a LEFT OUTER JOIN rather than inner joins.

A left outer join gets all the records in the left table tblCadaverLabs and all matching records and nulls from the other table.

mlmcc
0

Featured Post

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…

705 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