Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Help with SQL CASE SELECT

Posted on 2010-11-30
2
Medium Priority
?
259 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 2000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

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.
This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

722 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