Solved

Help with SQL CASE SELECT

Posted on 2010-11-30
2
249 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
2 Comments
 
LVL 32

Accepted Solution

by:
Erick37 earned 500 total points
Comment Utility
You need a THEN after the first CASE:

CASE WHEN  css.bErrFlag =0 THEN
0
 
LVL 1

Author Closing Comment

by:cheryl9063
Comment Utility
Perfect thanks so much!!
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

In this article I will describe the Detach & Attach 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 I will describe the Copy Database Wizard 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.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

762 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now