How can I get this output in Crystal Reports? - crystal-reports

I have been using SQL for around 2 years but I have recently started using Crystal Reports 2013.
I need to convert the below SQL to a Crystal Report:
SELECT COUNT(orders.order_no), reason_codes.reason_desc
FROM orders, reason_codes
WHERE orders.reason_code = reason_codes.reason_code
AND orders_reason.code IS NOT NULL
GROUP BY reason_codes.reason_desc
I'm lost as to how I go about getting the count completed. I am looking for an end result looking like:
COUNT(orders.order_no), reason_codes.reason_desc
500 Broken in Transit
400 Broken in Warehouse
It seems so easy to do it directly in SQL, as I have done above, but getting the desired output in Crystal Reports seems complicated, and I don't know where to start!

while creating database connection use command and use the same query exactly there and now in design place your fields in details.

Related

Crystal Reports 11: Finding where data is being filtered out

I am not a Crystal Reports developer.
In a legacy Crystal Report, I have been asked to find out why some Rows of data are being excluded from the Report Output at run time.
I copied the SQL behind the report and when I ran it in SQL Server Management Studio, those rows are not excluded. This is what leads me to conclude that there is a filter in the report itself that is excluding certain rows.
My question:
What are the different places in Crystal Reports 11 that I should look to find if any filtering is going on at run time?
I have looked at Formula fields, Selection formulas, Parameter Fields ... but though I have seen various code in those places, I have not found anything that looks like it will limit the output.
I would appreciate any pointers/suggestions.
Besides section suppression, look at:
Report, Selection Formula, Record...
Report, Selection Formula, Group...
Database joins
If the report SQL is the same as the one you checked in SSMS (including record selection formula , which will be the WHERE clause) , check report's details section suppression formula. A details row might be suppressed based on some row values

Replacing Crystal Report data source with store procedure

I used to create crystal reports by going into database expert, selecting tables and specifying the link manually. As I get a bit more comfortable with CR, there is a need for me to put the underlying SQL query into a store procedure to provide data to the report. But doing so will require me to rewrite the whole report which is time consuming.
So, my question is if there are any guru in the community that could and/or have tried to replace the underlying SQL (created by manually add table and links) with a store procedure or cmd without having to rewrite the whole report? I would love to get some hint of how to do that as I have a couple dozen of reports that need "adjustments" and time does not permit me to rewrite them all.
My Crystal Report versions are CR 2008 and CR 2012.
Thank you in advance.
In case you can use an existing software : this feature is available in a free Crystal reports viewer. Here is the documentation, which explains the use :
http://www.r-tag.com/Documents/RTag%20DataSource.pdf
... and here is where you can get your free license:
http://www.r-tag.com/Pages/FreeCrystalReportsViewer.aspx
Crystal does an absolutely horrible job of migrating from many tables to a single DB object, be it a Command or stored procedure.
You might be able to Database | Set datasource location... to map your SP to one of the many tables in the report (choose the one that has the most fields in use); I've never been able to get this feature to work trying to map a Command to a table.
'Best practice' for a really-poor 'feature' set:
create a formula field for each field that will be on the canvas, but isn't grouped (these fields won't be removed when you change datasources)
add the Command to the report; link tables if desired
manually switch grouping, record-selection formula, sorting, etc.

Crystal Reports Data disappearing

I am currently designing a report in crystal reports.
In the header I have the standard fields like Date/Time and a bunch of variables. In some cases one of the variables does not resolve to anything (it is empty).
When that variable is empty all the report data disappears.
I tried tricking Crystal Reports with creating a formular field, but again no luck!
Any ideas?
All data is received from a MySQL database and the field that causes the trouble is based on a custom query (command).
The actual query:
SELECT `teacher_name`
FROM `class_schedule`
LEFT JOIN (`teacher`, `cs_class`)
ON (`class_schedule`.`class_supporter`=`teacher`.`teacher_id` AND
`cs_class`.`cs_id`=`class_schedule`.`cs_id`)
WHERE `class_id`={?classId}
I have not worked with MySQL much at all. That said, I have never seen that construct for LOJs, so I am questioning the format. Pardon my ignorance if I am uninformed.
If you have CR Developer available, it might be interesting to see what query CR comes up with, and I guess a trace will show what is actually submitted to MySQL.
SELECT `teacher_name`
FROM `class_schedule` cs
LEFT outer JOIN `teacher` tch
on `cs`.`class_supporter`=`tch`.`teacher_id`
Left outer join `cs_class` csc
on `csc`.`cs_id`=`cs`.`cs_id`
WHERE `class_id`={?classId}
is the best I can recommend trying.

I am not getting data out of a fixed range in crystal report?

In my crystal report, I am actually filtering the data based on start date and end date.
But I am not getting data out of a fixed range(1-1-1985 to 31-12-2009).
Data I am getting is directly from DB table, I am not calling any procedure.
I checked all possible way to restrict/filter the data, I could not find anywhere they are filtering in the report.Still I am getting data from 1985 to 2009.
I am using Crystal Report 8.0.
Any idea how and where the data can be filtered out??
Thanks in advance for your time.
I did the following and now it is working fine.
Menu=> Database>Show SQL Query...>Reset
then I saved the report.
It is working fine now.
I feel it is a bug in Crystal Report or may be the behavior of the software(because I am new to crystal report).

Crystal Reports - Stored Procedure Syntax Question

When I drag a field from my stored procedure onto a formula (Crystal Reports 11), I get something like this:
{sp_YES_AccountSnapshot;1.ST0405_Ext}
What does the "1." represent?
I hope it refers to the table number... because I'd like to return two tables from the stored procedure and be able to access both from a report.
Thanks
I believe the semicolon one (";1") represents if the sp is active or not in the database.
I opened a report and connected to a datasource I frequently use and all of the sp's have ";1" except for 2 sp's which have ";0". Those sp's are old sp's which were deleted and do not show in the SQL Server Management Studio.
I don't believe that multiple tables can be pulled into a Crystal Report from an sp. When I just tried it on my system Crystal Reports closed out.