CHAPTER (1)
DESC            Desc emp
SELECT          Select * from emp;
                select empno, ename, job from emp;...
CHAPTER (2)
WHERE clause Select * from emp
             Where ename = ‘KING’
Comparison   = equal, > greater then, < less ...
CHAPTER (3)

                                      SINGLE ROW FUNCTIONS

THERE ARE 5 TYPES OF SINGLE ROW FUNCTIONS
CHARACT...
NUMBER FUNCTION

THERE ARE 3 TYPES OF NUMBER FUNCTIONS

1. ROUND
2. TRUNC
3. MOD
ROUND         SELECT ROUND(8974.34592,4),...
Upcoming SlideShare
Loading in …5
×

Chapter 1

1,241 views
1,201 views

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,241
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
23
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Chapter 1

  1. 1. CHAPTER (1) DESC Desc emp SELECT Select * from emp; select empno, ename, job from emp; Arthamatic select empno, ename, sal, sal+100 from emp Operation + - select empno, ename, sal, (sal+100)*12 from emp /* select empno, ename, sal, sal-100 from emp ALIAS Select empno AS “employee number, ename AS “employee name” from emp; CONCAT Select empno || ‘ , ‘ || ename ||job from emp; DISTINCT Select distinct (deptno) from emp;
  2. 2. CHAPTER (2) WHERE clause Select * from emp Where ename = ‘KING’ Comparison = equal, > greater then, < less then, >= greater then equal to, <= less operator then equal to , <> not equal to NULL value Select empno, ename, nvl(comm.,0) from emp; COMPARISION Between – select * from emp where sal between 2500 and 3000; OPERATOR In - select * from emp where sal in (2500,3500,4000); % means any Like – select * from emp where ename like ‘SMITH’ thing % - select * from emp where ename like ‘% MI%’ AND select * from emp where ename = ‘SMITH’ and deptno = 20; OR select * from emp where ename = ‘SMITH’ or sal > 2000; NOT IN In - select * from emp where sal NOT in (2500,3500,4000); ORDER BY Select * from emp order by sal;
  3. 3. CHAPTER (3) SINGLE ROW FUNCTIONS THERE ARE 5 TYPES OF SINGLE ROW FUNCTIONS CHARACTER FUNCTION NUMBER FUNCTION DATE FUNCTION CONVERSION FUNCTION GENERAL FUNCTIONS START WITH CHARACTER FUNCTION CHARACTER FUNCTION ALSO DIVIDE INTO TWO PARTS A. CASE MANIPULATION FUNCTION B. CHARACTER MANIPULATION FUNCTION CASE MANIPULATION FUNCTION CASE MANIPULATION FUNCTION FURTHER DIVIDE INTO 3 PARTS 1. UPPER FUNCTION 2. LOWER FUNCTION 3. INITCAP FUNCTION NOW START WITH UPPER FUNCTION UPPER FUNCTION CONVERT DATA INTO CAPITAL LETTER FROM SAMLL AND INITIAL CAPITAL LETTER example : raheel --> RAHEEL Raheel --> RAHEEL select ename, lower(ename), upper(ename), initcap(ename) from emp; SELECT HIREDATE, LOWER(HIREDATE) FROM EMP; UPPER SELECT * FROM EMP WHERE JOB=upper('salesman'); LOWER SELECT * FROM EMP WHERE JOB=lower('salesman'); INITCAP SELECT * FROM EMP WHERE JOB=initcap('salesman'); CHARACTER MANIPULATION FUNCTIONS THERE ARE SEVEN TYPES OF CHARACTER MANIPULATION FUNCTIONS 1. CONCAT 2. SUBSTR 3. LENGTH 4. INSTR 5. LPAD / RPAD 6 TRIM 7. REPLACE CONCAT SELECT CONCAT(ENAME,JOB) FROM EMP; SUCSTR SELECT ENAME, SUBSTR(ENAME,2,2), JOB , SUBSTR(JOB,3,5) FROM EMP LENGTH SELECT ENAME, LENGTH(ENAME) FROM EMP; INSTR SELECT ENAME , INSTR(ENAME,'A',2,1) FROM EMP; LPAD SELECT SAL, LPAD(SAL,10,'*') FROM EMP; RPAD SELECT SAL, RPAD(SAL,10,'*') FROM EMP; TRIM SELECT ENAME, JOB, SAL, TRIM('A' FROM ENAME) FROM EMP; REPLACE SELECT ENAME, REPLACE(ENAME, 'A', 'Z') FROM EMP;
  4. 4. NUMBER FUNCTION THERE ARE 3 TYPES OF NUMBER FUNCTIONS 1. ROUND 2. TRUNC 3. MOD ROUND SELECT ROUND(8974.34592,4), ROUND(8974.34592,3), ROUND(8974.34592,2), ROUND(8974.34592,1) FROM DUAL; TRUNC SELECT TRUNC(3456.98239,4), TRUNC(3456.98239,3), TRUNC(3456.98239,2) FROM DUAL MOD SELECT MOD(SAL,100) , SAL FROM EMP DATE FUNCTION (ADD DAYS IN DATE) - SELECT HIREDATE, HIREDATE+10 FROM EMP (ADD HOURS IN DATE) - SELECT ENAME, HIREDATE, HIREDATE+6/24 "INCREASE HOURS IN HIREDATE" FROM EMP; (ADD MINUTES IN DATE) SELECT ENAME, HIREDATE, HIREDATE+15/1440 FROM EMP (ADD SECOND IN DATE) SELECT SYSDATE, SYSDATE+15/(24*60*60) FROM EMP; HOW TO GET NO OF WEEKS SELECT (SYSDATE-HIREDATE)/7 FROM EMP; HOW TO GET NO OF MONTHS SELECT (SYSDATE-HIREDATE)/30 FROM EMP; NO OF YEARS SELECT (SYSDATE-HIREDATE)/365 FROM EMP; FINDING NO OF DAYS NO OF WEEKS NO OF MONTH NO OF YEARS SELECT HIREDATE, (SYSDATE-HIREDATE) "NO OF DAYS" , (SYSDATE-HIREDATE)/7 "NO OF WEEKS" , (SYSDATE-HIREDATE)/30 " NO OF MONTHS " , (SYSDATE-HIREDATE)/365 " NO OF YEARS" FROM EMP;

×