Solved

Crystal Reports or SQL to Solve this problem.....?

Posted on 2013-10-23
4
427 Views
Last Modified: 2013-10-23
I have the following two columns. I do not know if it is best to do this in the SP or in Crystal Reports. Currently the report uses an SP which Crystal REports points to. The MAC_CD is the Parameter used to pull records by users. They now want to switch and use the RAMS_CD....
One problem is when users pull the RAMS_CD 413000 it needs to return results for both MAC_CD 130 and 131.....How do I do that
Second problem....the MAC_CD has many extra codes not visible in the list that have Letters like S or P etc. If I need to get the following records matched up so that in the future the RAMS and MAC codes always pull the proper results back. How do I do that.
By the way the MAC codes are old and the RAMS codes are new. Your help is appreciated.

RAMS_CD	MAC_CD
413000	130
413000	131
413021	132
413031	133
415000	321
422000	220
450000	501
470000	700
471000	711
472000	721
473000	730
475000	751
485000	851
487000	870
489000	891
490000	901
491000	910
492000	921
494000	941
496000	960
498000	980
499000	990

Open in new window

0
Comment
Question by:ruavol2
  • 2
  • 2
4 Comments
 
LVL 40

Assisted Solution

by:Kyle Abrahams
Kyle Abrahams earned 500 total points
ID: 39594187
This is best done in SQL.  For the most part I always do as much of the row / grouping logic in sql and let crystal be the display formatter.

do you have a mapping table . . . if not you'll need to create one (see below).
The mac column can be varchar so that your records would always match.

At the end of the day it's just a matter of:

1)  change the parameter to be Rams_CD
2)  Create the mapping table if your don't have it.
3)  Change your table joins

eg:

select * from <tbl> where MAC_CD  = @mac_cd

becomes

select * from MappingTable m
join <tbl> t on m.Mac_Cd = t.Mac_Cd
where m.RAMS_CD = @rams_cd
0
 

Author Comment

by:ruavol2
ID: 39594381
Here is a question. If I have  the two columns in the table which do I make a primary key in the table. RAMS_CD or the MAC_CD or do I need something else.

I just created a table in SQL server.

I do not see where to give the table a name other than to save as Table 1
I have the records in an Excel Spreadsheet can I import them as they are above.
0
 
LVL 40

Accepted Solution

by:
Kyle Abrahams earned 500 total points
ID: 39594764
You would actually make both columns the primary key . . . you only want one combination of the RAMS_CD to MAC_CD.

(EG: you don't want
413000      130
413000      130
)


After you create the table, you could edit the top N rows and then copy and paste from excel.
0
 

Author Closing Comment

by:ruavol2
ID: 39595691
Very helpful thank you sir.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone 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 this article I will describe the Detach & Attach method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
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.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

829 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