Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.


How to Pull Data That Meets 2 Criteria For the Same Column

How to Pull Data That Meets 2 Criteria For the Same Column

I'm fairly new to Crystal and SQL. I'm wanting to pull a listing of people who meet 2 of the types of criteria for the same column by using a Crystal Report.

Let's say we have a column in our database called Contact Type. This column contains how a customer has contacted us. We want a listing of those people who have contacted us by phone with the abbreviation PHO and by email with the abbreviation EMA. We don't want to pull a listing of customers who has done either but instead who has done both.

Thanks in advance for your assistance!

RE: How to Pull Data That Meets 2 Criteria For the Same Column

I'm using Crystal Reports XI R2.

RE: How to Pull Data That Meets 2 Criteria For the Same Column

Try this:
  1. Group by client
  2. Create a formula like:


    If	{Table.Contact_Type} = 'PHO'
    Then 	1 
    If	{Table.Contact_Type} = 'EMA'
    Then 	3
    Else	2 
  3. Add a Group selection Formula like:


    DistictCount({Table.Contact_Type}, {Table.ClientGroup}) > 1 and
    Maximum({Table.Contact_Type}, {Table.ClientGroup}) = 3      and
    Minimum({Table.Contact_Type}, {Table.ClientGroup}) = 1 
Hope this helps


RE: How to Pull Data That Meets 2 Criteria For the Same Column

If you want the list of who has used both methods, not just one or the other, you'll have to do the following:

1. Add a second copy of the table that contains the contact type information to the report. Crystal will throw a warning asking if you want to "alias" the table and then add it with "_1" on the end of the table name.
2. Inner join from the original copy of the table (I'll call this "MyTable" in this example) to the aliased table ("MyTable_1")
3. Apply all of your original selection criteria to MyTable except the contact type.
4. Add the following to the selection criteria:
{MyTable.Connection_Type} = 'PHO' and
{MyTable_1.Connection_Type} = 'EMA'

Because of the inner join, this will only show people who have used both methods. However, you may need to turn on "Select Distinct Records" on the Database menu and you may have to do some additional grouping to make sure that you're not showing duplicate data.


DecisionFirst Technologies - Seven-time SAP BusinessObjects Solution Partner of the Year

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close