Solved

Is CASE Statement ANSI Standard or is specific to databases

Posted on 2010-08-22
3
654 Views
Last Modified: 2012-08-13
Hi,

Is the implementation of CASE statement in SQL ANSI Standard or each database has a standard of its own when using case statement

For example if a table column say recipe_class returns when doing a select

Main course
Vegetable
Starch
Salad
Hors d'oeuvres
Dessert
Soup

then How do I do case in all kinds of databases that will do this

case 'Main Course' then 'M'
case 'Vegetable' then 'V'
else  'EX'


thanks
-anshu
0
Comment
Question by:anshuma
  • 2
3 Comments
 
LVL 58

Accepted Solution

by:
cyberkiwi earned 334 total points
ID: 33498312
case
when recipe_class = 'Main Course' then 'M'
when recipe_class = 'Vegetable' then 'V'
else  'EX'
end
0
 
LVL 58

Assisted Solution

by:cyberkiwi
cyberkiwi earned 334 total points
ID: 33498360
ANSI-92 specifies the alternative form

CASE recipe_class
WHEN 'Main Course' then 'M'
when 'Vegetable' then 'V'
else  'EX'
end

But the first form has more support.  MySQL does not support this form, and from memory, Oracle doesn't either.
0
 
LVL 7

Assisted Solution

by:rashmi_vaghela
rashmi_vaghela earned 166 total points
ID: 33498424
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

So every once in a while at work I am asked to export data from one table and insert it into another on a different server.  I hate doing this.  There's so many different tables and data types.  Some column data needs quoted and some doesn't.  What …
Introduction: When running hybrid database environments, you often need to query some data from a remote db of any type, while being connected to your MS SQL Server database. Problems start when you try to combine that with some "user input" pass…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

758 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now