?
Solved

Crystal Reports

Posted on 2014-03-27
8
Medium Priority
?
599 Views
Last Modified: 2014-03-27
Is it possible to join multiple SQL sub queries in the add command of Crystal Reporting. I would like to have Query B join Query A as a left outer join using the report_Warranty field. Trying to avoid multiple input boxes

A: SELECT Report_Warranty, SUM(AMOUNT) AS TotalSales, COUNT(CUST_ID) AS CountofSales
FROM  SALES_Table
WHERE DATE BETWEEN {?BeginDate} AND {?EndDate}
GROUP BY Report_Warranty


B: SELECT    SUM(CLAIM_AMOUNT) AS ClaimTotal, COUNT(CUST_ID) AS ClaimCount, Report_Warranty
FROM    CLAIMS
WHERE Date BETWEEN {?BeginDate} AND {?EndDate}
GROUP BY Report_Warranty
0
Comment
Question by:Dave_CARSIT
  • 3
  • 3
  • 2
8 Comments
 
LVL 18

Expert Comment

by:vasto
ID: 39959669
It is possible but the moment you place fields from each query on the report , crystal engine will apply cross join.

You can use the first query in the main report and the subquery in  a subreport
0
 

Author Comment

by:Dave_CARSIT
ID: 39959713
Can you help with the correct join wording?
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 39959815
At least in CR2008 you can have more than 1 command for the report.  They can be linked in the linking expert

Try creating the 2 commands then linking them on the Report Warranty field

mlmcc
0
Granular recovery for Microsoft Exchange

With Veeam Explorer for Microsoft Exchange you can choose the Exchange Servers and restore points you’re interested in, and Veeam Explorer will present the contents of those mailbox stores for browsing, searching and exporting.

 
LVL 18

Expert Comment

by:vasto
ID: 39959823
If you want to join then do this inside one command. Having 2 separate commands joined inside Crystal will make the report very slow
0
 

Author Comment

by:Dave_CARSIT
ID: 39959953
If you want to join then do this inside one command

That is my preference, if possible.

But I`m not sure of correct way to state (first time using commands). Can someone help with left out join statement.

Thank you
0
 
LVL 101

Accepted Solution

by:
mlmcc earned 2000 total points
ID: 39959972
Try this

SELECT ST.Report_Warranty, SUM(ST.AMOUNT) AS TotalSales, COUNT(ST.CUST_ID) AS CountofSales, SUM(CL.CLAIM_AMOUNT) AS ClaimTotal, COUNT(CL.CUST_ID) AS ClaimCount
FROM  SALES_Table ST INNER JOIN CLAIMS CL  ON ST.Report_Warranty = CL.Report_Warranty
WHERE ST.DATE BETWEEN {?BeginDate} AND {?EndDate} AND CL.DATE BETWEEN  {?BeginDate} AND {?EndDate}
GROUP BY Report_Warranty

mlmcc
0
 

Author Closing Comment

by:Dave_CARSIT
ID: 39960014
Thank you
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 39960261
You probably should have given vasto an assist for his last comment about doing it in a single query.

The question can be reopened if you want to allow you to change the point allocation

mlmcc
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
What if you have to shut down the entire Citrix infrastructure for hardware maintenance, software upgrades or "the unknown"? I developed this plan for "the unknown" and hope that it helps you as well. This article explains how to properly shut down …
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Suggested Courses

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question