Books and articles about SQL Rambler's Top100 Сменить язык на: Русский 27 May 2024 16:37:48
Skip Navigation Links  


Print  Print version

Main page

About the use of the operator CASE

S. Moiseenko

In the help on a site the syntax of this operator is described and examples of its use are given. However these examples show an application of the CASE in the statement SELECT. Actually, the statement SELECT is the place of the most often use of the operator CASE, however it is not the only thing. We may use the CASE practically everywhere. Here I shall show some examples of its use in the other statements of the operator SELECT.

The statement WHERE.

The statement WHERE limits a target set to those lines which satisfy to a predicate in this statement. Let us suppose that we have such conformity between a memory size of the personal computer and a type of used operational system (conditionally):

RAM < 64     W95
RAM >=64 и < 128      W98
RAM >= 128      W2k

If we shall want to select computers by type of OS (we shall notice, that such field isn't in table PC) it is possible to write the following operator:

     WHEN ram <128 THEN 'W98'
     ELSE 'W2k' END

Here we choose the models fit to the operational system W98. The result of the execution of this query is given below.

  Print version

Usage of any materials of this site is possible
only under condition of mandatory allocation of the direct link to a site
on each page where used materials are placed.

 Main   Articles    Books 
Рейтинг Rambler's Top100 Alt Упражнения по SQL: обучение, тестирование, сертификация по языку SQL Copyright c 2002-2006. All rights reserved.