Sunday, August 15, 2010

Oracle 11g: Using Number Functions MOD

select last_name,
       salary
from employees
where job_id='SA_REP';

Results:
LAST_NAME                 SALARY                
------------------------- ----------------------
Tucker                    10000                 
Bernstein                 9500                  
Hall                      9000                  
Olsen                     8000                  
Cambrault                 7500                  
Tuvault                   7000                  
King                      10000                 
Sully                     9500                  
McEwen                    9000                  
Smith                     8000                  
Doran                     7500                  
Sewall                    7000                  
Vishney                   10500                 
Greene                    9500                  
Marvins                   7200                  
Lee                       6800                  
Ande                      6400                  
Banda                     6200                  
Ozer                      11500                 
Bloom                     10000                 
Fox                       9600                  
Smith                     7400                  
Bates                     7300                  
Kumar                     6100                  
Abel                      11000                 
Hutton                    8800                  
Taylor                    8600                  
Livingston                8400                  
Grant                     7000                  
Johnson                   6200                  

30 rows selected

==> SQL Queries using MOD


select last_name,
       salary,
       MOD(salary, 5000)
from employees
where job_id='SA_REP';

Results :
LAST_NAME          SALARY            MOD(SALARY,5000)      
------------------------- ---------------------- ----------------------
Tucker                    10000                  0                     
Bernstein                 9500                   4500                  
Hall                      9000                   4000                  
Olsen                     8000                   3000                  
Cambrault                 7500                   2500                  
Tuvault                   7000                   2000                  
King                      10000                  0                     
Sully                     9500                   4500                  
McEwen                    9000                   4000                  
Smith                     8000                   3000                  
Doran                     7500                   2500                  
Sewall                    7000                   2000                  
Vishney                   10500                  500                   
Greene                    9500                   4500                  
Marvins                   7200                   2200                  
Lee                       6800                   1800                  
Ande                      6400                   1400                  
Banda                     6200                   1200                  
Ozer                      11500                  1500                  
Bloom                     10000                  0                     
Fox                       9600                   4600                  
Smith                     7400                   2400                  
Bates                     7300                   2300                  
Kumar                     6100                   1100                  
Abel                      11000                  1000                  
Hutton                    8800                   3800                  
Taylor                    8600                   3600                  
Livingston                8400                   3400                  
Grant                     7000                   2000                  
Johnson                   6200                   1200                  

30 rows selected

No comments: