Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Case statement

Author  Topic 

gov_121
Starting Member

1 Post

Posted - 2011-05-24 : 15:05:12
Can any one please provide me the case statement for the below condition

If IBMCU='034' then plant is "US05" and if IBMCU="201" then plant ="US03" else skip the records

Thanks in advance

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2011-05-24 : 15:11:10
[code]
select case
when forum = 'yak corral' then 'no one answers'
when forum = 'script library' then 'everyone yells at me'
when forum = 'new to sql server progarmming' then 'I get my answer'
else 'who knows'
end
from MyTable
[/code]

Be One with the Optimizer
TG
Go to Top of Page

jcelko
Esteemed SQL Purist

547 Posts

Posted - 2011-05-24 : 21:02:08
There is a CASE expression in SQL; there is no CASE statement. Rows are not records. Please post real DDL. Learn to use ISO-11179 rules for the data element names, avoid needless dialect and use ISO-8601 temporal formats, codes and so forth. People cannot read your mind, so post your code and clear specs if you really want help.

--CELKO--
Books in Celko Series for Morgan-Kaufmann Publishing
Analytics and OLAP in SQL
Data and Databases: Concepts in Practice
Data, Measurements and Standards in SQL
SQL for Smarties
SQL Programming Style
SQL Puzzles and Answers
Thinking in Sets
Trees and Hierarchies in SQL
Go to Top of Page

Lumbago
Norsk Yak Master

3271 Posts

Posted - 2011-05-25 : 05:28:23
Joe: can you please edit your previous post and and set the part that is in your forum-signature in italics? I get REALLY sick of this rows/records/real ddl-crap all the time and I suspect that it's actually a part of your signature. And all this book-spam as well...I would think it's actually working against its purpose with all the shi* you're giving people.

- Lumbago
My blog-> http://thefirstsql.com/2011/02/07/regular-expressions-advanced-string-matching-and-new-split-function-sql-server-2008-r2/
Go to Top of Page

jcelko
Esteemed SQL Purist

547 Posts

Posted - 2011-05-25 : 20:50:51
My signature is my book list. When noobs quit making the same errors in SQL and netiquette over and over, why shouldn't I post the stock replies?

--CELKO--
Books in Celko Series for Morgan-Kaufmann Publishing
Analytics and OLAP in SQL
Data and Databases: Concepts in Practice
Data, Measurements and Standards in SQL
SQL for Smarties
SQL Programming Style
SQL Puzzles and Answers
Thinking in Sets
Trees and Hierarchies in SQL
Go to Top of Page

Lumbago
Norsk Yak Master

3271 Posts

Posted - 2011-05-26 : 01:23:56
quote:
Originally posted by jcelko

My signature is my book list. When noobs quit making the same errors in SQL and netiquette over and over, why shouldn't I post the stock replies?


Because the whole concept of a discussion forum like this is for people to ask questions they don't know the answer to, and for people that actually knoe the answer to tell it to them. Is a 15 year old boy a noob if he asks you where the carborator of a car sits?? He might be a potential world class race car driver but people like you that give him shit for trying to learn isn't really helping him along. You suck Joe, go retire or something.

- Lumbago
My blog-> http://thefirstsql.com/2011/02/07/regular-expressions-advanced-string-matching-and-new-split-function-sql-server-2008-r2/
Go to Top of Page
   

- Advertisement -