Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: function on a left outer join with no value Post Reply Post New Topic
Author Message
ReportJunkie
Newbie
Newbie
Avatar

Joined: 25 Jun 2012
Location: United States
Online Status: Offline
Posts: 4
Quote ReportJunkie Replybullet Topic: function on a left outer join with no value
     Posted: 25 Jun 2012 at 9:12am
Hi-I have a left outer join query (Table A-EMPLOYEE FILE) to Table B (EMPLOYEE TEST FILE) where I'm including all active employees and their most recent test.  As some users do not have any test scheduled, the test field (and any other fields from Table B) are blank.  I'm trying to create a function to highlight tests that are due (within 31 days of due date), overdue, or Not scheduled at all (there was no match to Table B).  The due and overdue are working fine, but I can't get the 'not scheduled' to show as there is no value.  Ie if today is 06/24/2012, then :
emp   test   due                 note
10       test   05/01/2012    overdue
25       test   07/01/2012    due
29       test   12/31/2012             (this is supposed to be blank) 
32                                                (would like 'Not scheduled', but it's blank)
 
Any ideas how to fix?
Thx for the help!
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 25 Jun 2012 at 10:44am
How are you getting the name of the test and the due date?  Is that in a separate table or is it only in the Employee Test File table?
 
-Dell
IP IP Logged
ReportJunkie
Newbie
Newbie
Avatar

Joined: 25 Jun 2012
Location: United States
Online Status: Offline
Posts: 4
Quote ReportJunkie Replybullet Posted: 25 Jun 2012 at 12:33pm
Hi Dell,
The test and due date data are from 1 table, while the emp# was looking at another table (and has other info, such as dept, emp name, etc).  The query looks at many tables, but I was trying to simplify my question by just using those 2 tables. 
-lisa
Thx for the help!
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 28 Jun 2012 at 3:37am
The challenge is how to determine whether a test is not scheduled.  Do you have logic for that?  Is there a "master" list of tests and when they might be due?
 
-Dell
IP IP Logged
ReportJunkie
Newbie
Newbie
Avatar

Joined: 25 Jun 2012
Location: United States
Online Status: Offline
Posts: 4
Quote ReportJunkie Replybullet Posted: 28 Jun 2012 at 4:12am
If there is no test than there is no data.  ie. employee 1 has a PPD scheduled for 07/01/2012, but employee 3 never had one scheduled.  This is why all the 'linked' data to the test table is blank - there was nothing to link to and therefore, even when I try to qualify the function by saying if isnull or = '', then put 'never scheduled', I can't get it to work.  That is my dilemma.  Thx again!
Thx for the help!
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 28 Jun 2012 at 4:46am
This is because there is no data to report off of.  You need a table with a list of all of the tests that are available.  Do you have access to create a view in the database?  If so, I would create one that that does a "Select Distinct" of the tests from the employee test data.  If not, you'll have to use a command for your report.  How are your SQL skills?
The command will have something like the following logic:
 
Select the data that you're currently using on the report.
 
UNION ALL
 
Select the appropriate employee info, class name, and a null date
from the employee table and (
 select the distinct test names for your date range - look at all records, not jut the specific employee records)
where the test name does not exist in the test table for this employee.
 
-Dell
IP IP Logged
ReportJunkie
Newbie
Newbie
Avatar

Joined: 25 Jun 2012
Location: United States
Online Status: Offline
Posts: 4
Quote ReportJunkie Replybullet Posted: 29 Jun 2012 at 6:44am

hi Dell -I cannot create views on our db-I only have the ability to query off the database, not make changes or views to the data.  I'm not sure how to accomplish the union all here, but I will check out in more detail this weekend and let you know if I have a breakthrough.  Thx again!

Thx for the help!
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum