Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Crystal Reports 2011 Table Join (data match issue)

Status
Not open for further replies.

icerubes

IS-IT--Management
Aug 2, 2012
11
AU
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.
 

I would probably first try replacing the master record table with a SQL command that includes all the data plus the quote number stripped of the supplementary counter. For instance:

select left(@test,charindex('.',@test) - 1) as QuoteNumberOnly, * from masterrecordtable --SQL Server syntax

Then you can join using the additional field:

command.QuoteNumberOnly = Table 2.Quote#_Add

Depending on your database, this might create a performance issue, but in this case I doubt it. If you try this and it runs too slowly post back and we can work around that.

This also assumes that the original quote will never have a '.' in it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top