i




 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
What is a CASE statement in SQL?
02-15-2013, 06:16 AM
Post: #1
What is a CASE statement in SQL?
Quote:CASE expressions can be used in SQL anywhere an expression can be used. Example of where CASE expressions can be used include in the SELECT list, WHERE clauses, HAVING clauses, IN lists, DELETE and UPDATE statements, and inside of built-in functions.

Example
Code:
DECLARE @CaseVar INT
SET @CaseVar = 3
SELECT
CASE @CaseVar
WHEN 1 THEN 'One'
WHEN 2 THEN 'Two'
WHEN 3 THEN 'Three'
ELSE 'Unknown'
END






View Asad Ali's profile on LinkedIn

Quote


Possibly Related Threads...
Thread: Author Replies Views: Last Post
  How to import table using INSERT statement? magnum_2007 0 992 01-21-2013 06:31 AM
Last Post: magnum_2007
Rainbow Table Creation and Selction in the same statement Usman 4 2,281 10-01-2010 04:40 PM
Last Post: Usman
  Inserting the results of the MERGE statement into another table arti.porwal20@gmail.com 1 1,428 09-28-2010 08:28 AM
Last Post: Rajesh Kumar Parbat
  Using MERGE to perform INSERT and UPDATE operations on a table in a single statement arti.porwal20@gmail.com 0 1,538 09-28-2010 05:38 AM
Last Post: arti.porwal20@gmail.com



User(s) browsing this thread: 1 Guest(s)