Solved

Crystal Reports 2011 Table Join

Posted on 2014-11-04
7
138 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 49

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 49

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

This guide will walk you through the essential considerations and tech stack for building scalable websites. Know how to grow your business the smart way!
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 ?
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

628 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