You are on page 1of 2

SELECT * FROM TAB; (to see all the tables exists under that user) select * from emp;

(to see all the records of a table) desc emp; (to see different columns from a table) where clause : it is basically used to filter the records on the base of any con dition. it generally follows the from clause. SELECT * FROM EMP WHERE SAL>1000; ORDER BY CALUSE : LAST CLAUSE. used for sorting the data. select * from emp order by ename; select * from emp order by sal; select * from emp order by comm aesc; select * from emp order by comm desc; ( null values will come first) to see diff deptno in a table select distinct deptno from emp; select deptno from emp group by deptno; select deptno from emp where deptno<>10 group by deptno; sum,max,min, count select deptno,sum(sal) from emp group by deptno; all the columns used in select clause except in group functions should be use in group by clause. select max(sal) from emp; select max(sal) ,deptno from emp group by deptno; select max(sal) from emp where sal not in (select max(sal) from emp group by dep tno) group by deptno / n tables join n-1 join conditions normal/equi join left outer join right outer join cross join select empno,ename,dname from emp,dept where emp.deptno=dept.deptno; select empno,ename,emp.deptno from emp cross join dept left outer join : left all + right matching

right outer join : right all + left matching. SELECT SUBSTR(ENAME,1,3),ENAME FROM EMP SELECT ROUND((SYSDATE-HIREDATE)/365) FROM EMP

You might also like