?
Solved

Sybase SQL CASE statement problem

Posted on 2007-08-01
2
Medium Priority
?
6,776 Views
Last Modified: 2008-01-09
Hello Experts, I am creating a SQL query in Crystal Reports to run against a Sybase db. My select statement is
SELECT
ad.line1
  case
    when en.firm is not NULL then en.firm
     else en.first_name || ' ' || en.last_name AS Name
 end
  case
    when en.taxid is not NULL then en.taxid
     else en.ssno
 end
 FROM  
The CASE statements are not working. What am I doing wrong? Should I use COALESCE instead? If so, how would I write that?
0
Comment
Question by:JohnPell
2 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 2000 total points
ID: 19611973
My select statement is
SELECT
ad.line1
  case
    when en.firm is not NULL then en.firm
     else en.first_name || ' ' || en.last_name
 end AS Name
  case
    when en.taxid is not NULL then en.taxid
     else en.ssno
 end as tax_ssno
 FROM

you had the " as name " on the wrong place
0
 

Author Comment

by:JohnPell
ID: 19612080
Thanks! I did have to had a comma between the case statements, but it works fine.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
What we learned in Webroot's webinar on multi-vector protection.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

809 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