CoSpringsGuy
IS-IT--Management
This is very odd and I am hoping someone can give me some tips as to why this happens. Using Crystal 2011 and pulling data from an Intersystems Cache database. I have dealt with null values as opposed to empty spaces many times but this one has me baffled.
Creating a report using the following sql code for a table..
My problem lies in the line CASE WHEN(ISNULL(User_Master_2.Department_Number,"0")) = "0" THEN "COL" ELSE DU_COLL_CREDIT_FOR_LEGAL_N_B.COLL_CREDIT END as Shared_Credit
This line is basically changing the output to a static value if there is no math in the second table. I know there are many records in the table where User_Master_2.Department_Number should come back as null or empty which is why I use a Left Outer Join in the From Clause. When I run the report, it initially acted as I expected it to but after noticing I was missing a lot of dollars, I created a similar report in Crystal (no Command Table) using a Left Outer Join again on those two tables and all nulls and blank values were returned. I created a formula to determine which of those fields are empty and which are null.
Here is the odd part. Comparing what was returned in the two reports, the SQL code is returning only the EMPTY fields and not the NULL fields. Ao are they NULL or not? The NULL Values are not being returned at all. I cant see anywhere in the rest of my code where I may be making a mistake. This was my first attempt at a left outer join with other tables involved so I thought that might be the issue but if it were I wouldnt think I would get any null or empty values at all. NOTE: There is ALWAYS a value in User_Master_2.User_ID. DU_COLL_CREDIT_FOR_LEGAL_N_B.COLL_CREDIT is the field which may either have a match to the other table, be null or blank.
Whether you have a thought on this or not ... thanks for reading!!!
_____________________________________
Crystal Reports 2011 and XI
Intersystems Cache 2012 ODBC connection
Creating a report using the following sql code for a table..
Code:
SELECT Payment_History.OCCURENCE_DATE, DU_COLL_CREDIT_FOR_LEGAL_N_B.COLL_CREDIT, Payment_History.COLLECTOR,User_Master.Department_Number, User_Master_2.Department_Number,
max(Payment_History.OCCURENCE_DATE) as LastDate,
CASE WHEN(ISNULL(User_Master_2.Department_Number,"0")) = "0" THEN "COL" ELSE DU_COLL_CREDIT_FOR_LEGAL_N_B.COLL_CREDIT END as Shared_Credit,
SUM(CASE WHEN (Payment_History.REVERSE_CODE in ("C","N") ) THEN -Payment_History.AMT_REFUNDED ELSE Payment_History.AMT_REFUNDED END) as Ref_Amt
(NOTE: There are many more statements similar to the one above this line but I took them out for reading clarity)
FROM SQLUser.Payment_History Payment_History, SQLUser.User_Master User_Master, SQLUser.DU_COLL_CREDIT_FOR_LEGAL_N_B DU_COLL_CREDIT_FOR_LEGAL_N_B left join SQLUser.User_Master User_Master_2
ON DU_COLL_CREDIT_FOR_LEGAL_N_B.COLL_CREDIT = User_Master_2.User_ID
WHERE (Payment_History.ACCOUNT_NUM=DU_COLL_CREDIT_FOR_LEGAL_N_B.ACCOUNT_NUM)
AND (Payment_History.COLLECTOR = User_Master.User_ID)
and Payment_History.OCCURENCE_DATE>={?startdate}
AND Payment_History.OCCURENCE_DATE<={?enddate}
and Payment_History.PAYMENT_TYPE not in ("CRJ","DBJ")
AND Payment_History.COLLECTOR <> DU_COLL_CREDIT_FOR_LEGAL_N_B.COLL_CREDIT
AND User_Master.Department_Number in (400,500,501,900,901,902,903,904,905,906,907)
GROUP BY Payment_History.ACCOUNT_NUM
My problem lies in the line CASE WHEN(ISNULL(User_Master_2.Department_Number,"0")) = "0" THEN "COL" ELSE DU_COLL_CREDIT_FOR_LEGAL_N_B.COLL_CREDIT END as Shared_Credit
This line is basically changing the output to a static value if there is no math in the second table. I know there are many records in the table where User_Master_2.Department_Number should come back as null or empty which is why I use a Left Outer Join in the From Clause. When I run the report, it initially acted as I expected it to but after noticing I was missing a lot of dollars, I created a similar report in Crystal (no Command Table) using a Left Outer Join again on those two tables and all nulls and blank values were returned. I created a formula to determine which of those fields are empty and which are null.
Here is the odd part. Comparing what was returned in the two reports, the SQL code is returning only the EMPTY fields and not the NULL fields. Ao are they NULL or not? The NULL Values are not being returned at all. I cant see anywhere in the rest of my code where I may be making a mistake. This was my first attempt at a left outer join with other tables involved so I thought that might be the issue but if it were I wouldnt think I would get any null or empty values at all. NOTE: There is ALWAYS a value in User_Master_2.User_ID. DU_COLL_CREDIT_FOR_LEGAL_N_B.COLL_CREDIT is the field which may either have a match to the other table, be null or blank.
Whether you have a thought on this or not ... thanks for reading!!!
_____________________________________
Crystal Reports 2011 and XI
Intersystems Cache 2012 ODBC connection