Hi All,
CR 8.5, SQLServer 2K
Within Crystal I want to write a subselect query that accepts a paramater. I know you can achieve similar results with Sub reports, but they can slow reports down.
How can you do it with pure Crystal?
The scenario is, you want to see every part number in the item master table and the total usage over a given period of time from the stock transaction table.
Item---->Transcation (Left outer join)
As I understand it, you can add a filter to the transaction table to limit it to a paramter date range as this effectively turns the quey into a inner join. (this then limits all items that exist in the transaction table that meet the date range)Correct?
You can remove the filter on the transaction table and have a variable that 'sums' the qty given the date range.
e.g. if transdate in {?min date} to {?max date} then qty else 0
again, this can be slow because you need to go through every transaction record and if you have a 1 to many link, the number of items shown will be wrong.
In SQL it would be something like
Select t1.Item, t3.qty from item t1 left outer join (Select t2.item, t2.qty from transaction t2 where t2.date >=01/01/2000 and t2.date <=01/01/2002) t3
this is the most efficient code.
How do you do this in Crystal with the Dates been parameters? Can ver 9 or 10 handle this?
Or do you best handle this as a stored procedure?
Can anyone confirm/clarify show simple example of a SP of the above.
Thanks
Fred
CR 8.5, SQLServer 2K
Within Crystal I want to write a subselect query that accepts a paramater. I know you can achieve similar results with Sub reports, but they can slow reports down.
How can you do it with pure Crystal?
The scenario is, you want to see every part number in the item master table and the total usage over a given period of time from the stock transaction table.
Item---->Transcation (Left outer join)
As I understand it, you can add a filter to the transaction table to limit it to a paramter date range as this effectively turns the quey into a inner join. (this then limits all items that exist in the transaction table that meet the date range)Correct?
You can remove the filter on the transaction table and have a variable that 'sums' the qty given the date range.
e.g. if transdate in {?min date} to {?max date} then qty else 0
again, this can be slow because you need to go through every transaction record and if you have a 1 to many link, the number of items shown will be wrong.
In SQL it would be something like
Select t1.Item, t3.qty from item t1 left outer join (Select t2.item, t2.qty from transaction t2 where t2.date >=01/01/2000 and t2.date <=01/01/2002) t3
this is the most efficient code.
How do you do this in Crystal with the Dates been parameters? Can ver 9 or 10 handle this?
Or do you best handle this as a stored procedure?
Can anyone confirm/clarify show simple example of a SP of the above.
Thanks
Fred