Q18:Select records using group by;
18.1

SELECT deptno,sum(sal)FROM emp GROUP BY deptno

18.2

SELECT deptno,sum(sal) FROM emp GROUP BY deptno,ename ,empno


Q19:Select records using group by and having clause;

SELECT deptno,sum(sal) GROUP BY deptno HAVING deptno>20


Q20:select with-in select;
20.1

SELECT * FROM emp WHERE max(sal)<(SELECT max(sal) FROM emp)

20.2

SELECT * FROM emp WHERE deptno=(SELECT deptno FROM dept);

20.3

SELECT * FROM emp WHERE deptno NOT IN (SELECT deptno FROM dept);


Q21:create a table by selecting record from another table;

CREATE TABLE emp2 AS SELECT * FROM emp;

Q22:Select records using exist;

SELECT deptno FROM dept d WHERE EXISTS (SELECT * FROM emp e WHERE d.deptno = e.deptno);

Q23:Select sysdate;

SELECT sysdate FROM dual;

Q24:Select constraint name, constraint_type;

SELECT constraint_name, constraint_type
FROM user_constraints
WHERE table_name = 'emp';

 


Q25:Select  nextval, currval from sequence;
25.1

SELECT emp_sequence.nextval FROM dual

25.2

SELECT emp_sequence.currval FROM dual