Search code examples
crystal-reportsleft-join

Crystal Reports: How do I list Table A and Table B EXCLUSIVELY in 1 report?


Apology: I've been experimenting with something for a while but I'm not trained in relational databases so I don't even know the language to use when trying to search for an answer.

Table Descriptions:

  • Table A - List of Clients
  • Table B - Client Orders under $100
  • Table C - Client Orders Over $100

Background: I want to make a report that lists EVERY client. Some clients have entries in B and C, some have only B, some have only C (And some have none!). I want my report to list a client (A), and then each B if they have B's, and then each C if they have C's. I'd like the B's and C's to be in different columns (I think they have to be.)

Problem: I've tried using all sorts of joins that I could do and the closest I've gotten is:

  • A is Left Outer Joined (Enforced From) to B
  • A is also Left Outer Joined (Enforced From) to C

Result: For each change in B, it's listing every C. I.e. if a client has 5 orders in B, and 10 orders in C, my report lists the same B 5 times in the B column and then each C once in the C column. Then it moves onto the next B in the B column (Repeating itself for each C -- etc). This client should have 15 rows, but it currently makes 50.

Question: What join am I supposed to use? I don't understand any sort of explanation of joins...


Solution

  • I think subreports may be your friend here. You group your report by clients from Table A, then create 2 detail sections (a, b) and in Detail A you put a subreport that uses Table B (linked to client in table a) and shows the orders under $100 and in Detail B you put a subreport that uses table C (also linked to client in table a) that shows orders over $100.

    Let me know if that makes sense,

    Chris