Learn T-SQL Commands with Samples
Skip Navigation Links
Skip Navigation Links.
Expand DatabaseDatabase
Expand TableTable
Expand ViewView
Expand Stored ProcedureStored Procedure
Expand Data FilteringData Filtering
Expand Data GroupingData Grouping
Expand JoinsJoins
Expand TriggerTrigger
Expand CursorCursor
Expand OperatorsOperators
Expand ConstraintsConstraints
Expand FunctionsFunctions
Collapse Conditional ProcessingConditional Processing
Expand LoopingLooping
Expand Error HandlingError Handling
Expand v.IMP Queriesv.IMP Queries
Expand XMLXML
Expand Query PerformanceQuery Performance
Expand QueriesQueries
Expand NormalizationNormalization
Expand CreateCreate
     

Simple Case

 
EMP
ID Name Country Salary
1 Vijay India 6000
2 Bill USA 8000
3 Kris France 3000
      SELECT *,

      CASE Country
          WHEN    'USA'       THEN    'High Tax'
          WHEN    'India'     THEN    'Low  Tax'
          WHEN    'France'    THEN    'No Tax'
          ELSE                        'Not Applicable'
      END

      AS        Tax

      FROM      EMP
    
      
Output
ID Name Country Salary Tax
1 Vijay India 6000 High Tax
2 Bill USA 8000 High Tax
3 Kris France 3000 No Tax