Hi,
I am using a CR 8.5 with an ODBC connection to a DB2 table on the mainframe. The table has about 45,000 records. The problem I have is that the simple report takes very long too run. It takes about 5 minutes to run. It is not a problem now but in 2 years when there will be hundreds of thousands of records, it will be a big problem!
I have a main report with one table. The main report also has a subreport. The problem is in the record selection in my main report. There is an IF statement in the record selection. When I look in the Show SQL query box, the where clause is missing.
This is what I would like the report to accomplish:
If the current day I run the report is the 1st, 2nd or 3rd day of the current month, then I would like to extract all records from the previous month.
For example, if I run this report on 2004/01/03 (YMD), then it must extract all records where {NEW_BUS_DM.TRANSACTION_DT} is between 2003/12/01 and 2003/12/31.
On the other hand, if the current day I run the report is >= the 4th day of the current month, then it must extract all records from the first day of the current month until the last day of last week which is Saturday.
For example, if I run this report on 2004/01/13, then it will extract all records where {NEW_BUS_DM.TRANSACTION_DT} is between 2004/01/01 and 2004/01/10.
This is my record selection in the main report (which takes very long to run):
if Day(CurrentDate) in [1, 2, 3] then
{NEW_BUS_DM.TRANSACTION_DT} >= DateSerial(Year(CurrentDate), Month(CurrentDate) - 1, 1) and
{NEW_BUS_DM.TRANSACTION_DT} <= DateSerial(Year(CurrentDate), Month(CurrentDate), 1 - 1) and
{NEW_BUS_DM.TRANSACTION_TYPE} = "New Issue" and
{NEW_BUS_DM.CHANNEL_NAME} <> "Independent Career" and
{NEW_BUS_DM.CHANNEL_NAME} <> "N/A"
else
{NEW_BUS_DM.TRANSACTION_DT} >= DateSerial(Year(CurrentDate), Month(CurrentDate), 1) and
{NEW_BUS_DM.TRANSACTION_DT} <= maximum(LastFullWeek) and
{NEW_BUS_DM.TRANSACTION_TYPE} = "New Issue" and
{NEW_BUS_DM.CHANNEL_NAME} <> "Independent Career" and
{NEW_BUS_DM.CHANNEL_NAME} <> "N/A"
This is what is in my Show SQL query:
SELECT
NEW_BUS_DM.`TRANSACTION_DT`, NEW_BUS_DM.`TRANSACTION_TYPE`, NEW_BUS_DM.`SALES_COUNT`, NEW_BUS_DM.`CHANNEL_NAME`
FROM
`NEW_BUS_DM` NEW_BUS_DM
How can I improve the run time and include the where conditions of my records selection in my SQL?
Thank you in advance.
I am using a CR 8.5 with an ODBC connection to a DB2 table on the mainframe. The table has about 45,000 records. The problem I have is that the simple report takes very long too run. It takes about 5 minutes to run. It is not a problem now but in 2 years when there will be hundreds of thousands of records, it will be a big problem!
I have a main report with one table. The main report also has a subreport. The problem is in the record selection in my main report. There is an IF statement in the record selection. When I look in the Show SQL query box, the where clause is missing.
This is what I would like the report to accomplish:
If the current day I run the report is the 1st, 2nd or 3rd day of the current month, then I would like to extract all records from the previous month.
For example, if I run this report on 2004/01/03 (YMD), then it must extract all records where {NEW_BUS_DM.TRANSACTION_DT} is between 2003/12/01 and 2003/12/31.
On the other hand, if the current day I run the report is >= the 4th day of the current month, then it must extract all records from the first day of the current month until the last day of last week which is Saturday.
For example, if I run this report on 2004/01/13, then it will extract all records where {NEW_BUS_DM.TRANSACTION_DT} is between 2004/01/01 and 2004/01/10.
This is my record selection in the main report (which takes very long to run):
if Day(CurrentDate) in [1, 2, 3] then
{NEW_BUS_DM.TRANSACTION_DT} >= DateSerial(Year(CurrentDate), Month(CurrentDate) - 1, 1) and
{NEW_BUS_DM.TRANSACTION_DT} <= DateSerial(Year(CurrentDate), Month(CurrentDate), 1 - 1) and
{NEW_BUS_DM.TRANSACTION_TYPE} = "New Issue" and
{NEW_BUS_DM.CHANNEL_NAME} <> "Independent Career" and
{NEW_BUS_DM.CHANNEL_NAME} <> "N/A"
else
{NEW_BUS_DM.TRANSACTION_DT} >= DateSerial(Year(CurrentDate), Month(CurrentDate), 1) and
{NEW_BUS_DM.TRANSACTION_DT} <= maximum(LastFullWeek) and
{NEW_BUS_DM.TRANSACTION_TYPE} = "New Issue" and
{NEW_BUS_DM.CHANNEL_NAME} <> "Independent Career" and
{NEW_BUS_DM.CHANNEL_NAME} <> "N/A"
This is what is in my Show SQL query:
SELECT
NEW_BUS_DM.`TRANSACTION_DT`, NEW_BUS_DM.`TRANSACTION_TYPE`, NEW_BUS_DM.`SALES_COUNT`, NEW_BUS_DM.`CHANNEL_NAME`
FROM
`NEW_BUS_DM` NEW_BUS_DM
How can I improve the run time and include the where conditions of my records selection in my SQL?
Thank you in advance.