Go Premium for a chance to win a PS4. Enter to Win


SQL Z97 if INSUB and Greater than 199

Posted on 2014-02-28
Medium Priority
Last Modified: 2014-02-28
How can I get matlxfer.xtype to equal 'Z97' if matlxfer.xtype = 'INVSUB' and matlxfer.xfer_vndlot > '199' and '551' if it's less.

 SELECT matlxfer.fm_cost_ctr ,
        matlxfer.to_cost_ctr ,
               CASE matlxfer.xfer_vndlot
        WHEN '200' THEN '1200'
        WHEN '201' THEN '1201'
        WHEN '202' THEN '1202'
        WHEN '203' THEN '1203'
        WHEN '204' THEN '1204'
        WHEN '205' THEN '1205'
        WHEN '206' THEN '1206'
        WHEN '207' THEN '1207'
      ELSE matlxfer.xfer_vndlot
      END AS xfer_vndlot   ,
        CASE matlxfer.xtype
          WHEN 'ADDINV' THEN '552'
          WHEN 'INVSUB' THEN '551'

Open in new window

xfer_vndlot	ADJUSTMENT
108	551
109	551
110	551
1200	551
1201	551
1202	551
1203	551
1204	551
1205	551
1206	551
1207	551

Open in new window

Question by:gpsdh
LVL 27

Accepted Solution

Shaun Kline earned 2000 total points
ID: 39895974
You can nest CASE Statements:
CASE matlxfer.xtype
          WHEN 'ADDINV' THEN '552'
          WHEN 'INVSUB' THEN
                 CASE WHEN matlxfer.xfer_vndlot > 199 THEN 'z97' ELSE '551' END

Author Closing Comment

ID: 39895987

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

I have a large data set and a SSIS package. How can I load this file in multi threading?
What if you have to shut down the entire Citrix infrastructure for hardware maintenance, software upgrades or "the unknown"? I developed this plan for "the unknown" and hope that it helps you as well. This article explains how to properly shut down …
Via a live example, show how to setup several different housekeeping processes for a SQL Server.
Viewers will learn how the fundamental information of how to create a table.

916 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