We help IT Professionals succeed at work.
Get Started

adding case statment with SELECT

anderdw2 asked
Last Modified: 2012-06-27
I had asked how to get the LEFT JOIN to work with the following statement and got a great response.  However, now I'm stuck on another issue.    s.class and s.nir are numeric identifiers that do not have an associated table as a reference.   Can I add a case statement within the select to show their textual value?

Close Data

SELECT   s.batch, s.code, s.class as Package_Type, s.nir as NIR_type, s.account, s.arrival, s.return, f.name as Feed_Type, s.describe, s.due, b.item as Special_Item, b.amount as Special_Amt, ;
             s.farmname, c.first, c.last, c.business, c.discount, c.pricetier, s.postage, c.billto, c.address1, c.city, c.state, c.zip, ;
             c.fax, c.phone, c.email;  
   FROM samples s ;
  INNER JOIN samplexp x ON s.sampleid = x.sampleid ;
  INNER JOIN clients c ON s.account = c.account ;
  INNER JOIN feedcode f ON s.feed_type = f.feed_type ;
  LEFT JOIN billitem b ON s.sampleid = b.sampleid ;
  WHERE s.batch = 11748 ;
    AND x.location="LANCSAMPLE"
COPY TO C:\lancasterTest\lancBill TYPE DELIMITED

Watch Question
Founder, Software Engineer, Data Scientist
This problem has been solved!
Unlock 1 Answer and 7 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE