Skip to main content

Hi everyone, i am trying to create cathegories for my pie chart. The categories would describe the Value of the "Case" based on payments (can be NULL) and the rest of the reserves 8also can be NULL) for the Case. I have started with the following description of the Categories:

(CASE WHEN 

(

  ("CEL_SHUK_CASES"."ZAHLUNGEN" + "CEL_SHUK_CASES"."RESTRESERVEN")>=0 AND ("CEL_SHUK_CASES"."ZAHLUNGEN" + "CEL_SHUK_CASES"."RESTRESERVEN") <1000

  OR 

  (("CEL_SHUK_CASES"."ZAHLUNGEN") IS NULL AND ("CEL_SHUK_CASES"."RESTRESERVEN")>=0 AND ("CEL_SHUK_CASES"."RESTRESERVEN")<1000)

  OR 

  (("CEL_SHUK_CASES"."RESTRESERVEN") IS NULL AND ("CEL_SHUK_CASES"."ZAHLUNGEN")>=0 AND ("CEL_SHUK_CASES"."ZAHLUNGEN")<1000)

  OR 

  (("CEL_SHUK_CASES"."RESTRESERVEN") IS NULL AND ("CEL_SHUK_CASES"."ZAHLUNGEN") IS NULL)

)

THEN '<1.000 €'

ELSE

(CASE WHEN 

(

  (("CEL_SHUK_CASES"."ZAHLUNGEN" + "CEL_SHUK_CASES"."RESTRESERVEN")>=1000 AND ("CEL_SHUK_CASES"."ZAHLUNGEN" + "CEL_SHUK_CASES"."RESTRESERVEN") <10000)

  OR 

  (("CEL_SHUK_CASES"."ZAHLUNGEN") IS NULL AND ("CEL_SHUK_CASES"."RESTRESERVEN")>=1000 AND ("CEL_SHUK_CASES"."RESTRESERVEN")<10000)

  OR 

  (("CEL_SHUK_CASES"."RESTRESERVEN") IS NULL AND ("CEL_SHUK_CASES"."ZAHLUNGEN")>=1000 AND ("CEL_SHUK_CASES"."ZAHLUNGEN")<10000)

THEN '<10.000 €'

ELSE

'BLABLA'

END)

END)

 

The problem i am facing is that i get a 4th cathegory "-" with all the combinations on NULLs that were not inclued into the category '<1000'.

My idea is that the values with NULLs that do not conform with the first "Case when" are thrown away and not used further. This is nonsece and i hope there is a way to fix ma pql.

TNX

Maria

Okay, i kinda solved the problem. the statement " ("CEL_SHUK_CASES"."ZAHLUNGEN" + "CEL_SHUK_CASES"."RESTRESERVEN")>=0" was not executed for the case when payments or reserves were NULL. So I had to rebuild the query to a very unarrtactive one by "case-whening" every single combination starting witn NULL-NULL then NULL+'<1000', NULL+'<10000'...,'<1000'+ NULL and so on. The final one had like 20 "case when" statements instead of 5.


Reply