Thanks for the reply. I have done till here. Say for example the table t1 contains
the following fileds.
Cust_id
Name
Address
City
State
Zip
Age
Date of Purchase.
Now i want a report that conatins only Name,Address and Age. I want to do this in CR. So i connected to the database and inside SQL expressions Field i wrote the following query,
SELECT name,address,age FROM t1
Is this correct. But i got a error which says
Error in compiling SQL Expression
Database Connector Error:'42000:[Microsoft][ODBC SQL Server Driver][SQL Server][Incorrect sybtax near the keyword 'select'.[Database Vendor Code:156]'
Note :I am establishing connection between CR and SQL server through ODBC driver.
So is the problem with the connection or with the query i wrote.
I have one more question. Should someone know little about SQL to query the database in CR . I am asking this question because there are no programmers here. So once i leave is it possible to do all extarctions using CR.
Now, I show you 2 problems:
1. To report only some fields, you choose the database, and the table you want to report (click on the Datatabase Fields item in the Field Explorer panel to open a wizard for it), then you drag and dop the columns you want onto the report. Very simple!
2. Solving your error. It is a syntax error. And here is the solution:
"Doing a SELECT in a SQL Expression field:
When teaching SQL expression fields I have always tried to stress that SQL Expressions are different from SQL Statements. A SQL Expression is a column in the report, where a SQL statement is a full query. My short version of this was to say "a SQL Expression can't do a "SELECT". Well I recently learned that this is not precisely true. Under certain situations, a SQL Expression CAN do a completely separate select from the main report.
The main limitation is that it can only return a single value. So you probably will need a summary function. The following example comes from the Xtreme Sample Database:
(SELECT Max ( Orders.`Order ID`)
FROM `Orders` Orders)
Normally a CR SQL Expression would error on the SELECT, but if you put this expression in parentheses, Crystal will pass it to the database as a separate query. Amazingly, the column being queried does not even have to come from one of the tables in the report, but can be from another table in the database. In the past I would have recommended doing this via subreport. The advantage of a SQL Expression is that the value returned can be used to control things like Selecting, Sorting and Grouping in the report. Of course, if you need to select multiple rows or multiple columns, you will need a subreport. "
(This lecture is from Ken Hamady, www.kenhamady.com)
Is it suiteable to your problem? I think so!