SQL Tutorial : DRL / DQL - NUMBER, SYSDATE
Let's learn about next topic: NUMBER , SYSDATE
NUMBER:
********
4 3 5 . 6 6 7
-3 -2 -1 0 1 2 3
ROUND:
ROUND(435.467,0)=> 435
ROUND(435.667,0)=> 436ROUND(435.667,1)=> 435.7
ROUND(435.667,-1)=> 440
ROUND(435.667,-2)=> 400
ROUND(465.667,-1)=> 470
ROUND(435.667,-3)=> 0
ROUND(535.667,-3)=> 1000
TRUNC:
TRUNC(435.467,0)=> 435
TRUNC(435.667,0)=> 435
TRUNC(435.667,1)=> 435.6
TRUNC(435.667,-1)=> 430
TRUNC(435.667,-2)=> 400
TRUNC(435.667,-3)=> 0
TRUNC(535.667,-3)=> 0
- MOD GIVES THE REMAINDER:
MOD(4,3) => 1
DATE:
SYSDATE => SYSTEM DATE
ARITHMETIC OPERATIONS:
- SELECT SYSDATE,SYSDATE+2,SYSDATE-2
FROM DUAL
- SELECT LAST_NAME,SALARY ,
ROUND((SYSDATE-HIRE_DATE)/365) YEARSFROM EMPLOYEES
MONTHS_BETWEEN :
********************
- SELECT LAST_NAME,
ROUND(MONTHS_BETWEEN (SYSDATE,HIRE_DATE)/12) YEARS
FROM EMPLOYEES
ADD_MONTHS:
**************
- SELECT SYSDATE,ADD_MONTHS(SYSDATE,-2),
ADD_MONTHS(SYSDATE,3)
FROM DUAL
NEXT_DAY:
***********
- SELECT NEXT_DAY(SYSDATE,'FRIDAY'),
NEXT_DAY(SYSDATE,2)
FROM DUAL
LAST_DAY:
**********
- SELECT LAST_DAY(SYSDATE)
FROM DUAL
ROUND:
*******
- SELECT ROUND(SYSDATE,'MONTH'),
ROUND(ADD_MONTHS(SYSDATE,4),'YEAR')
FROM DUAL
No comments:
Post a Comment