DATOR


사칙연산 사용하기( +, -, * , / ) SQL Fundamental


PURPOSE

SCOPE & APPLICATION

KEY IDEA

(KEY WORD : 수식연산자)

SUPPOSITION

DESCRIPTION

◆ 예제 : SELECT LIST에 수식 연산자 사용하기

   SQL> SELECT last_name, salary, commission_pct,
     2         salary * commission_pct / 100  COMMISSION
     3  FROM   s_emp
     4  WHERE  title = 'Sales Representative'
     5* ORDER BY  salary * commission_pct / 100

   LAST_NAME            SALARY         COMMISSION_PCT             COMMISSION
   -------------------- -------------- -------------------------- ------------------------
   Magee                   1400                    10                   140
   Sedeghi                 1515                    10                   151.5
   Giljum                  1490                    12.5                 186.25
   Nguyen                  1525                    15                   228.75
   Dumas                   1450                    17.5                 253.75

   FROM절을 제외한 SQL의 모든 부분에 수식 연산자를 사용할 수 있다.

◆ 예제 : 조건절에 수식 연산자 사용하기

   SQL> SELECT last_name, salary, commission_pct,
     2         salary * commission_pct / 100 COMMISSION
     3  FROM   s_emp
     4  WHERE  title = 'Sales Representative'
     5  AND    salary * commission_pct / 100 > 200
     6* ORDER BY salary * commission_pct / 100

◆ 예제 : 수식 연산자의 우선순위

   SQL> SELECT last_name, salary,
     2         salary * 12 + 100 "ANNUAL COMPENSATION"
     3  FROM   s_emp
     4  WHERE  dept_id = 41;

   LAST_NAME                 SALARY ANNUAL       COMPENSATION
   ------------------------- ------------------- ----------------------------------------
   Ngao                            1450                    17500
   Urguhart                        1200                    14500
   Maduro                          1400                    16900
   Smith                            940                    11380

   수식 연산자의 우선순위는 (*,/) (+,-) 순이다.

 

Leave Comments