I'm writing a report to calculate margin on our parts. The costs for each part (materials, labor, overhead, subcontracting) are rolled up periodically and stored in a different table.
My problem is how to retrieve only the data I want. I have a set of tables that look like this:
[tt]Invoice Table
Invoice # Item # Invoice Date
12321 1 2001-02-10
Cost Rollup Table
Part # Cost Rollup Date
1 2001-01-15
1 2001-02-01
1 2001-02-14
1 2001-03-30[/tt]
My delimma is how to get the row from the Cost Rollup Table that is just prior to the date in the Invoice Table. By default I get a row in my details section for every entry in the Cost Rollup Table:
[tt]Invoice # Item # Invoice Date Cost Rollup Date
12321 1 2001-02-10 2001-01-15
12321 1 2001-02-10 2001-02-01
12321 1 2001-02-10 2001-02-14
12321 1 2001-02-10 2001-02-30[/tt]
I really want to retrive only the row with the largest Cost Rollup Date that is less than or equal to the Invoice Date:
[tt]Invoice # Item # Invoice Date Cost Rollup Date
12321 1 2001-02-10 2001-02-01[/tt]
I talked to our Baan/Oracle programmer, and she recommended that I (1) select all rows with a Cost Rollup Date less than or equal to the Invoice Date from the Cost Rollup Table into a temporary table, (2) sort the temporary table descending, and (3) retrieve the first row from the temporary table. That's how she would do it using the native Baan report writer.
Any suggestions how to do this in CR?
I'm using native Crystal Reports v7.0 to retrieve item costing data from Baan using the free direct-connect DLL. The reports are compiled to an EXE file.
My problem is how to retrieve only the data I want. I have a set of tables that look like this:
[tt]Invoice Table
Invoice # Item # Invoice Date
12321 1 2001-02-10
Cost Rollup Table
Part # Cost Rollup Date
1 2001-01-15
1 2001-02-01
1 2001-02-14
1 2001-03-30[/tt]
My delimma is how to get the row from the Cost Rollup Table that is just prior to the date in the Invoice Table. By default I get a row in my details section for every entry in the Cost Rollup Table:
[tt]Invoice # Item # Invoice Date Cost Rollup Date
12321 1 2001-02-10 2001-01-15
12321 1 2001-02-10 2001-02-01
12321 1 2001-02-10 2001-02-14
12321 1 2001-02-10 2001-02-30[/tt]
I really want to retrive only the row with the largest Cost Rollup Date that is less than or equal to the Invoice Date:
[tt]Invoice # Item # Invoice Date Cost Rollup Date
12321 1 2001-02-10 2001-02-01[/tt]
I talked to our Baan/Oracle programmer, and she recommended that I (1) select all rows with a Cost Rollup Date less than or equal to the Invoice Date from the Cost Rollup Table into a temporary table, (2) sort the temporary table descending, and (3) retrieve the first row from the temporary table. That's how she would do it using the native Baan report writer.
Any suggestions how to do this in CR?
I'm using native Crystal Reports v7.0 to retrieve item costing data from Baan using the free direct-connect DLL. The reports are compiled to an EXE file.