Using Sub Query in Sql Query - Crystal Report 5.0 
Author Message
 Using Sub Query in Sql Query - Crystal Report 5.0

Hi,
        This Query works perfectly in SQLServer 6.5.

SELECT
CctrName,CctrDescription,CctrBillable,CctrCreatDate,CctrLastModDate,CctrUser
Id,
(Select count(*) from Aggregation b where b.CctrId = a.CctrId) as
noofmeasure
FROM
 Cost_Center a
ORDER BY
CctrName ASC

Please note that I am using a Sub Query to get a value which is from
different table and I have to show it in the Report.

The problem is when I Paste the Query in Crystal Report 5.0 Show SQL Query,
It gives the error message
"ODBC error:( Microsoft) ( ODBC SQL Server Driver) (SqlServer) Line 1 :
Incorrect syntax near ')',

followed by "Sql Server Error"

When I go back to Show SQL Query, the Query appears like this:

SELECT
    Cost_Center."CctrName", Cost_Center."CctrDescription",
Cost_Center."CctrBillable", Cost_Center."CctrCreatDate",
Cost_Center."CctrLastModDate", Cost_Center."CctrUserId"
FROM
    Aggregation b
WHERE
    b.CctrId = a.CctrId) as noofmeasure FROM  Cost_Center
ORDER BY
    CctrName ASC

How do I get my Value? Please help me.

Thanks
Lalitha Jayaraman



Tue, 04 Apr 2000 03:00:00 GMT  
 Using Sub Query in Sql Query - Crystal Report 5.0

In my experience, CR doesn't know about every SQL
construct, and subqueries like yours appear to be a case
in point.
I would be inclined to remove the subquery and allow CR to
do the counting itself, something like:

SELECT
CctrName,CctrDescription,CctrBillable,CctrCreatDate,
CctrLastModDate,CctrUser,
Id, b.CctrId, a.CctrId
FROM
Cost_Center a, Aggregation b
where
a.CctrId *= b.CctrId /* I think */
ORDER BY
CctrName ASC

and in the report have a Count(b.Cctrld)
--
Les Schmalzbach
(remove nospam- to reply).



Quote:
> Hi,
>    This Query works perfectly in SQLServer 6.5.

> SELECT

CctrName,CctrDescription,CctrBillable,CctrCreatDate,CctrLastModDate,CctrUser

Quote:
> Id,
> (Select count(*) from Aggregation b where b.CctrId = a.CctrId) as
> noofmeasure
> FROM
>  Cost_Center a
> ORDER BY
> CctrName ASC

> Please note that I am using a Sub Query to get a value which is from
> different table and I have to show it in the Report.

> The problem is when I Paste the Query in Crystal Report 5.0 Show SQL
Query,
> It gives the error message
> "ODBC error:( Microsoft) ( ODBC SQL Server Driver) (SqlServer) Line 1 :
> Incorrect syntax near ')',

> followed by "Sql Server Error"

> When I go back to Show SQL Query, the Query appears like this:

> SELECT
>     Cost_Center."CctrName", Cost_Center."CctrDescription",
> Cost_Center."CctrBillable", Cost_Center."CctrCreatDate",
> Cost_Center."CctrLastModDate", Cost_Center."CctrUserId"
> FROM
>     Aggregation b
> WHERE
>     b.CctrId = a.CctrId) as noofmeasure FROM  Cost_Center
> ORDER BY
>     CctrName ASC

> How do I get my Value? Please help me.

> Thanks
> Lalitha Jayaraman



Tue, 04 Apr 2000 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Q: Pass a SQL query from VB to crystal report sub-report

2. sub-report (2 query's ) in crystal reports

3. sub-report (2 query's ) in crystal reports

4. parameters to a sql query, used with Crystal Reports

5. SQL Query - MAX, Grouping and Sub query

6. How to change SQL query in Sub-report

7. Passing Parameters to Crystal Report 5.0 (Stored Procedure Query )

8. SQL query works, Crystal query doesn't

9. how can I build 2 queries in 1 query(VB SQL query)

10. Summarising data from sub-reports in Crystal Reports Pro 5.0

11. Crystal Report based on an SQL query

12. SQL Help - SQL sub-query

 

 
Powered by phpBB® Forum Software