How can I add conditions to query used by Crystal Reports?

1.7k Views Asked by At

I have a view that I'm supposed to use for a crystal report.

When I run run a select on it (in SSMS) without any conditions it takes a couple of hours (and returns a few million rows). With conditions, it takes ~ 5 seconds.

In Crystal Reports, I've added conditions to the select Expert ->Group formula. When I go to Database -> Show Sql Query, it simply shows all the columns in the view followed by "from viewname".

When I try to run the report and look at the query running in the database, I see that it is querying all the data from the view without any conditions. From what I'm seeing, Crystal Reports can only filter data that is returned by a query.

Is there some way that Crystal reports can add conditions to the view prior to sending the query to the database?

1

There are 1 best solutions below

0
Rolan On BEST ANSWER

Apparently, select Expert -> Group Formula is the wrong place to filter.

In order to use the parameter for the query, you need to place your formula in the select Expert -> Record Formula.

Then go into the Database menu and select "Perform Grouping on Server."

This should add the conditions to the query itself.