Solved

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

Posted on 2013-10-23
4
430 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
I have a large data set and a SSIS package. How can I load this file in multi threading?
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 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.

632 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