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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

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

Status
Not open for further replies.

Computergal2104

IS-IT--Management
Oct 21, 2013
2
0
0
US
Hi,
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!
Computergal2104
 
Try this:
[ol 1]
[li]Group by client[/li]
[li]Create a formula like:
Code:
If	{Table.Contact_Type} = 'PHO'
Then 	1 
Else
If	{Table.Contact_Type} = 'EMA'
Then 	3
Else	2
[/li]
[li]Add a Group selection Formula like:
Code:
DistictCount({Table.Contact_Type}, {Table.ClientGroup}) > 1 and
Maximum({Table.Contact_Type}, {Table.ClientGroup}) = 3      and
Minimum({Table.Contact_Type}, {Table.ClientGroup}) = 1
[/li]
[/ol]

Hope this helps

Cheers
Pete
 
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.

-Dell

DecisionFirst Technologies - Seven-time SAP BusinessObjects Solution Partner of the Year
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top