I am preparing a BIRT report on Eclipse and I need to put a date filter. I have more than 1 field with date in the report, and some of them are empty. The problem is: How do I use the correct date (not to use) to use as a parameter for the filter? I am trying to do something like this:
Select the case when D___1 is zero, then D___2 when D___2 is zero, then D___3 when D___3 is zero, then D___4 when D___4 zero , Then the data D___5 end
and then it will return a valid date and I will use it as a filter. But it does not seem to work any thoughts? thank you in advanced.
Are you trying to display a non-null column before D1, D2 , D3, D4, D5? If this is the case, then you COALESCE (D1, D2, D3, D4, D5)
.
because your case statement will not work as expected for you, because
a) "==" Oracle does not have valid syntax
b) Compare it to & lt; Something & gt; = Void
(and accordingly, and
) always returns zero - ie. It's neither true nor false, instead you should check for it: & lt; Something & gt;
(And vice versa: & lt; some & gt; is not empty)
).
c) Your logic is incomplete - you are checking what to do if D1 through D1 is zero, but no, if D1 (or D2 or ...) is not zero, then what happens.
Assume that you want non-zero values first, it should give you an idea with sample_data (select one 1 call1, tap call2, tap call3, dual union, all With the addition of tap call 1, 2 to 2, and how you can do it with the logic of the matter, double tap call from dual union 3, all selected tap call 1, tap call 2, 3 to dual to 3 All selected faucet calls from the Union 1, 4 calls 2, 5 from Coal 3 to all selected 6 CO1, 7 CO 2, 8 Coal 3 Dual Associations Select all 9 colons 1, tap col2, double to 10 col3) col1, col2, col3, colas (col1, col2, col3) first_non_null_coalesce if call 1 is not zero then call 1 w o col2 is not zero, then col2, When col3 is not zero, col3 end first_non_null_case_logic from sample_data; COL1 COL2 COL3 FIRST_NON_NULL_COALESCE FIRST_NON_NULL_CASE_LOGIC ---------- ---------- ---------- --------------- -------- ------------------------- 1 1 2 2 3 3 3 4 5 4 4 6 7 8 6 6 9 10 9 9
No comments:
Post a Comment