×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

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.

Students Click Here

Crystal Reports 8.5: Conditional SQL Expression?

Crystal Reports 8.5: Conditional SQL Expression?

Crystal Reports 8.5: Conditional SQL Expression?

(OP)
Informix Database
Crystal Reports 8.5

Hello, im trying to create an SQL expression (Sub Query) in Crystal Reports which based on a conditional statement. At current I have the below SQL expression:

CODE

%INV. To Date:

(
SELECT
    sum (po_order_line.order_line_amnt)
FROM
    popes:popesdba.po_order po_order,
    popes:popesdba.po_order_line po_order_line,
    popes:popesdba.po_invc po_invc
WHERE
    po_fi_cnrct.cnrct_id = po_order.fi_cnrct_id AND
    po_order.order_id = po_order_line.order_id AND
    po_order.order_stat_cd = po_order_line.order_stat_cd AND
    po_order.invc_id = po_invc.invc_id
)

I then have the below 'formula' which I display in the report :

CODE

@INV. To Date:

if isnull({%INV. To Date}) then 0 else {%INV. To Date}

The reason I've used the formula is to produce a "0" if any null values are returned, previously when I tried totally the %INV. To Date SQL expression the report just returned a null value and ignored any other values.

The report is working correctly at the moment but I was wondering if I could produce a 'Conditional Statement' in a SQL Expression to replicate what the above SQL Expression and formula do.

I am thinking something like:

CODE

IF  NOT IS NULL (sum (po_order_line.order_line_amnt)) THEN
    SELECT sum (po_order_line.order_line_amnt)
    ELSE 0
FROM
    popes:popesdba.po_order po_order,
    popes:popesdba.po_order_line po_order_line,
    popes:popesdba.po_invc po_invc
WHERE
    po_fi_cnrct.cnrct_id = po_order.fi_cnrct_id AND
    po_order.order_id = po_order_line.order_id AND
    po_order.order_stat_cd = po_order_line.order_stat_cd AND
    po_order.invc_id = po_invc.invc_id

Could someone please advise me whether the above is possible in Crystal? And/or I should be posting in an Informix forum.
 

RE: Crystal Reports 8.5: Conditional SQL Expression?

(OP)
cheers will look into the NVL function

RE: Crystal Reports 8.5: Conditional SQL Expression?

(OP)
PHV:

NVL function worked perfect cheers

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! Already a Member? Login

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