Link to home
Start Free TrialLog in
Avatar of sainisherry
sainisherry

asked on

How to write sql statement in crystal report 10.?

I made a simple report in CR 10.
I want to display one field independent of the mail query.
So how can i write a sql to render the field.
And one more point where can i write this sql query.
help me guys.
its urgent.

bye
ASKER CERTIFIED SOLUTION
Avatar of bdreed35
bdreed35
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
If I understand the question correctly you want to actually get the report to run 2 select statements ? The first statement is the report datasource and you want to retrieve an unrelated field using the 2nd SQL statement.

If I am correct the easiest way to accomplish this is to insert a subreport and use this to return the unrelated data.

Gary
Avatar of Mike McCracken
Mike McCracken

Avatar of sainisherry

ASKER

Gary , u r on the right track.

How can i resolve this issue. I just want to fetch a value from separate sql and print on the report.

thankx
Build a new report that gets the information.  Use that as a subreport and then use the Sharing data method outlined in my 3rd link.

mlmcc
You can also write the SQL statement in a SQL Expression, as long as it returns only one value, and avoid the Subreport.

Create a new SQL Expression from the field explorer.
Add your SQL statement in the editor, and enclose the whole statment in parenthesis.
Save and Close.
Add the SQL Expression field ot the report.
Run the report.

This can be a bit faster, and easier than using a subreport since the value will be returned with the original reports recordset.
With a subreport, you will have to deal with shared variables in if you need the value for any calculations.