Solved

Crystal Reports

Posted on 2014-03-27
8
579 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 100

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
 
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
Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

 

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 100

Accepted Solution

by:
mlmcc earned 500 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 100

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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

937 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now