Solved

Crystal Reports 2011 Table Join

Posted on 2014-11-04
7
135 Views
Last Modified: 2014-11-11
Crystal Reports 2011.  Connecting via ODBC  to Pervasive 11 database.

I wish to link 2 tables.  The first table is the Master record holder.  The second table holds all the underlying detail.

The join is very simple - Table 1.Quote# right outer join Table 2.Quote#_Add. (not enforced).

e.g. Table 1.Quote# 45199 = Table 2.Quote#_add 45199

However the database provides a function allowing additional items to be added to the master record but identified as supplementaries.  i.e. they are form part of the master record as a whole but also can be identified as additional to the original value.  For example: initial quote $1000 additional damage found during repair to the value of $500.  This $500 would be added as a supplementary of the original quote rather than creating a whole other quote.

The way the database does this is simple.  It adds a sequential counter.  The master record will always be XXXXX.00 and any supplementaries will be sequential XXXXX.01, XXXXX.02 etc.

Supplementaries are infrequent but without the correct join there is holes within our datasets.

So the issue is how do I join the two tables to include any supplementaries?  

The current join Table 1.Quote# right outer join Table 2.Quote#_Add. (not enforced).  Includes all information but excludes all supplementaries.  This would be because the is no longer an exact match once the suffix changes incrementally but I don't know how to work around this.........

Appreciate your help.
0
Comment
Question by:Murphy1992
[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
  • 3
  • 2
  • 2
7 Comments
 
LVL 13

Expert Comment

by:Koen Van Wielink
ID: 40423257
Can you join the master table to a second instance of this table, basically treating it the same way as you would the detail table? So it would use the master table to get the quote number, then join to itself under another alias to get the supplementary charges, and it would join to the detail table for the remaining details.
0
 

Author Comment

by:Murphy1992
ID: 40423285
Thank for response.
Know where you are heading with this but still believe the issue is the exclusion as it isn't an exact match.  i.e. Crystal provides only for an exact match.  It doesn't allow for value >= as master record and < next master record.

e.g.

Table 1.Quote#
44291.00

Table 1.Quote#_Add
44291.00
44291.00
44291.00
44291.00
44291.01
44291.02
44291.02
44291.02

It's the all the records >=44291 and <44292 that should be matched to master record 44291.

At this stage Crystal matches only records equal to 44291.00
0
 
LVL 13

Accepted Solution

by:
Koen Van Wielink earned 350 total points
ID: 40423290
Ok, I see your problem. Do you have the option to create a custom query? I would tackle this through a nested subquery or a temporary table (using a stored procedure).
You can extract the portion of the field before the period separately with something like this:

select T2.*
From (Select substring(T1.Quote#, 0, charindex('.',T1.Quote#)) as 'MasterRecord, T1.*)
            From Table1 T1) as T2

Open in new window


I hope this syntax is usable on a pervasive database, I'm not familiar with the exact syntax. But if not the idea would apply I'm sure.
Apply the same logic on your second table with the details, and you have the field on which you can join the data together.
0
Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

 
LVL 48

Assisted Solution

by:PortletPaul
PortletPaul earned 150 total points
ID: 40423481
I have no idea why you start with a right outer join, is there a particular reason for that choice?

also: instead of "charindex" you need "locate" then you can use LEFT() or SUBSTRING()

LEFT( field, LOCATE('.',field)-1 )

SUBSTRING( field, 1, LOCATE('.',field)-1 )
0
 

Author Comment

by:Murphy1992
ID: 40425372
Thanks for responses.

Right outer join was an attempt to get around exact matching ....... wasn't many choices :/

The database is a proprietary database which we cannot access however I can create some external tables linked via ODBC and try your suggestions.  Not ideal but definitely a potential work around.

Thanks
0
 
LVL 13

Expert Comment

by:Koen Van Wielink
ID: 40425389
Paul, just want to check something about your comment. You say "don't use charindex". Is that because it's a Pervasive database? On MS SQL charindex would be the correct choice right?
Also didn't realize that substring isn't a zero based function.
0
 
LVL 48

Expert Comment

by:PortletPaul
ID: 40425494
Sorry, Yes, for Pervasive use LOCATE()

If it was mssql the CHARINDEX() would be used
(and not locate :)
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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, you will read about the trends across the human resources departments for the upcoming year. Some of them include improving employee experience, adopting new technologies, using HR software to its full extent, and integrating artifi…
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
XMind Plus helps organize all details/aspects of any project from large to small in an orderly and concise manner. If you are working on a complex project, use this micro tutorial to show you how to make a basic flow chart. The software is free when…

732 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