Solved

Crystal Reports

Posted on 2014-03-27
8
574 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
Comment Utility
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
Comment Utility
Can you help with the correct join wording?
0
 
LVL 100

Expert Comment

by:mlmcc
Comment Utility
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
Comment Utility
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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 

Author Comment

by:Dave_CARSIT
Comment Utility
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
Comment Utility
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
Comment Utility
Thank you
0
 
LVL 100

Expert Comment

by:mlmcc
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

771 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

10 Experts available now in Live!

Get 1:1 Help Now