Solved

Help with SQL CASE SELECT

Posted on 2010-11-30
2
257 Views
Last Modified: 2012-05-10
See my code below.. I want the code to put the field sComment to stated below if the berrorflag is 0 otherwise I want the sComment to have something else.. The second "case" keword is highlighted and I'm not sure what I'm doing wrong
CASE 
	WHEN  css.bErrFlag =0
     CASE (css.sDeliveryMethod)
	  WHEN 'fax'    THEN 'Web customer requests the listed invoice number: ' + (css.sTransactionNo) + ' to be sent via: ' 
		    + (css.sDeliveryMethod) + ' to ' + COALESCE(css.sPhone_Fax, '') 
	  WHEN 'email'  THEN 'Web customer requests the listed invoice number: ' +  (css.sTransactionNo) + ' to be sent via: ' 
		    + (css.sDeliveryMethod) + ' to ' + COALESCE(css.semail, '') 
	  WHEN 'e-mail' THEN 'Web customer requests the listed invoice number: ' + (css.sTransactionNo) + ' to be sent via: ' 
		    + (css.sDeliveryMethod) + ' to ' + COALESCE(css.semail, '') 
	  WHEN 'mail'   THEN 'Web customer requests the listed invoice number:  ' +  (css.sTransactionNo) + ' to be sent via: ' 
		    + (css.sDeliveryMethod) + ' to ' + COALESCE(css.saddress1, '') + '; ' + COALESCE(css.sAddress2, '') 
		    + '; ' + COALESCE(css.scity, '') + ', ' + COALESCE(css.sstate, '') + '  ' + COALESCE((right(css.szip,5)), '') 
     ELSE 'Customer requested invoices be sent and did not choose a delivery method. '
     END 
  ELSE 'Error in case:'+(css.sErrMsg)
  END sComment,

Open in new window

0
Comment
Question by:cheryl9063
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 32

Accepted Solution

by:
Erick37 earned 500 total points
ID: 34239579
You need a THEN after the first CASE:

CASE WHEN  css.bErrFlag =0 THEN
0
 
LVL 1

Author Closing Comment

by:cheryl9063
ID: 34239589
Perfect thanks so much!!
0

Featured Post

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question