User`s guide

6.5.5 Using SQL expressions where appropriate
SQL expressions are like formulas, but they are written in Structured Query Language (SQL). They are
useful in optimizing report performance because the tasks they execute are normally performed on the
database server (as opposed to a regular formula, which is sometimes executed on the local machine).
Don't use SQL expressions exclusively, because Crystal Reports includes its own formula language,
which is much more powerful than standard SQL. Both Crystal Syntax and Basic Syntax allow you to
enhance and hone your formulas in ways that are either difficult or impossible with SQL. In certain
circumstances, however, creating and using SQL Expression fields can speed up the processing of
your reports.
6.5.5.1 Key uses of SQL Expression fields
To maintain optimum report processing speeds, avoid using formulas (whether Crystal or Basic syntax)
within record selection formulas. Instead, replace the original formula with an equivalent SQL Expression
field, and then incorporate the SQL Expression field into your record selection formula. Doing so will
greatly improve the chances of your record selection being pushed down to the server.
In addition, avoid sorting, grouping, or totaling on a formula field (whether Crystal or Basic syntax).
Instead, replace the original formula field with an equivalent SQL Expression field, and then sort, group,
or total on the SQL Expression Field. Again, this will greatly improve the chances of the processing
being done on the server.
Finally, if your database supports Case Logic, and your report needs to summarize an If-Then-Else
formula calculation, replace the formula with an SQL Expression field. In such cases, SQL Expression
fields enable Crystal Reports to perform the report's grouping on the server. For more information, see
Using SQL Expressions for Case Logic.
Related Topics
The SQL language
SQL Expression fields
Using enhanced record selection formulas
6.6 Improving grouping, sorting, and totaling
2012-03-14125
Designing Optimized Web Reports