SQL III-8

The flashcards below were created by user dau108 on FreezingBlue Flashcards.

  1. Using advanced SQL value expressions
    • 􏱦 Using the CASE conditional expressions
    • 􏱦 Converting a data item from one data type to another
    • 􏱦 Saving data entry time by using row value expressions
  2. CASE conditional expression
    SQL has a CASE statement and a CASE expression. A CASE expression is only part of a statement — not a statement in its own right. In SQL, you can place a CASE expression almost anywhere a value is legal. At run time, a CASE expression evaluates to a value. SQL’s CASE statement doesn’t evaluate to a value; rather, it executes a block of statements.

    You can use the CASE expression in the following two ways:

    • 􏰏 Use the expression with search conditions. CASE searches for rows in a table where specified conditions are True. If CASE finds a search condition to be True for a table row, the statement containing the CASE expression
    • makes a specified change to that row.

    􏰏 Use the expression to compare a table field to a specified value. The outcome of the statement containing the CASE expression depends on which of several specified values in the table field is equal to each table row.
  3. using CASE with search conditions
  4. CASE
    • WHEN condition1 THEN result1
    • WHEN condition2 THEN result2
    • ...
    • WHEN conditionn THEN resultn
    • ELSE resultx
    • END
  5. updating values based on a condition
    Image Upload
  6. avoiding conditions that cause error
    Image Upload
  7. using case with values
    Image Upload
  8. a special CASE- NULLIF
    • UPDATE FLIGHT
    • SET RefuelStop = CASE
    • WHEN RefuelStop = ‘San Jose’
    • THEN NULL
    • ELSE RefuelStop
    • END ;

    • UPDATE FLIGHT
    • SET RefuelStop = NULLIF(RefuelStop, ‘San Jose’) ;
Author:
dau108
ID:
145532
Card Set:
SQL III-8
Updated:
2012-04-04 14:44:50
Tags:
SQL III
Folders:

Description:
SQL III-8
Show Answers: