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

Crystal Reports Where Clause

Status
Not open for further replies.

bdmoran

MIS
Nov 7, 2011
87
US
Hello,

I am new to using Crystal Reports and quickly learned that the syntax is different from SQL Server. I was wondering if there is something similar to a where or having clause.

I created a formula:

IF isnull({v_cust_name.name_first})then {v_cust_name.name_last} else {v_cust_name.name_first} + ' ' + {v_cust_name.name_last}

However, I wanted to add in a WHERE clause. For example:

IF isnull({v_cust_name.name_first})then {v_cust_name.name_last} [highlight #EF2929]WHERE {v_cust_name.primary_code} = n[/highlight] else {v_cust_name.name_first} + ' ' + {v_cust_name.name_last}

Does this make sense?

Hope you can help!

 
Just add to IF part of the clause

IF isnull({v_cust_name.name_first}) and {v_cust_name.primary_code} = n
then {v_cust_name.name_last} else {v_cust_name.name_first} + ' ' + {v_cust_name.name_last}

Ian
 
That won't work because I only want to pull the secondary contact if the first name is null.
 
So in other words, if first name is NULL, I want the first and last name of the Secondary contact (primary_code = n)
 
Can you explain the primary_code = n part of the formula?

Why does the code Ian posted not work?




[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
It's because if that cust_first_name field is NULL then primary code is always going to be 'y'. So it's never true that cust_first_name will be NULL and primary_code will be "N".

It's alright anyways -- I ended up working it out using different fields. I appreciate all the input though.

Thank you!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top