I'm working in Cognos 10.1.1
I have requirement for 62 list reports that differ by columns.
If we group them based of the category, 31 reports show BOD and 31 show EOD data.
EOD (T-2 data) and BOD (T-1 data).
Here is the requirement. In order to reduce the number of reports we have planned to mingle these two date logics in a single reports.
Case
when [Time Selection] = 'EOD' then
[As of date] = _add_days(current_date,-2)
else
[As of date] = _add_days(current_date,-1)
end
This works fine but there is some decrease in the report performance. It is running longer than the separate reports.
I tried using a macro but there is no difference between the above case condtion and the macro when the sql is generated.
Please suggest me a solution to increase the report performance.
We are using db2.
Thanks in advance.
Looking at your code without knowing your issue, I wouldn't suspect that your code would produce a performance problem. That said I avoid using =, <> etc. when working with dates. Instead, I use the built-in date math functions.
Try the following:
CASE
WHEN [Time Selection] = 'EOD' THEN
_days_between([As of date],current_date) = -1
ELSE
_days_between([As of date],current_date) = -2
END
There is also another syntax that may also perform better than your existing code. We can eliminate the CASE statement and use simple boolean logic in your filter:
([Time Selection] = 'EOD' AND _days_between([As of date],current_date) = -1)
OR
([Time Selection] <> 'EOD' AND _days_between([As of date],current_date) = -2)
This syntax takes advantage of an optimization in most languages, including SQL, where if the first term of an AND returns false the line is skipped without evaluating the second term as the result of the AND could never be true.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.