Review of SQL Commands
With reports based on tables, views, or stored procedures, Crystal Reports does the background work of generating a database query. This query incorporates the fields you have used in the report, any sorting or filtering youve applied, and even some calculations. This is one of the strengths of Crystal Reportsyou don need to be an expert at writing SQL to use the product. All that complexity is abstracted away from the user designing the report. However, sometimes the person developing the report is familiar with the SQL language, and perhaps is also the database administrator. In situations like this, people often want to write their own query for several reasons, including the following:
- An already defined query, which has the required fields, is in use elsewhere.
- The user wants to optimize her query beyond what Crystal Reports provides out-of-the-box.
- The user wants to perform a complex query that is beyond what Crystal Reports automatically generates; for example, a union query.
The SQL Commands feature is meant to address these needs. Rather than adding a table or view to a report, you can add a SQL command. This command represents a SQL query that you will type in. After this SQL command is created, it is treated just like a table in that it contains fields that can be used in the report and can be linked to other tables or SQL commands.
Категории