SQL QUREIES
select * from emp , proj , depart ;
Create a table Manager with columns Empno, Ename, Job, Deptno, Salary with structure and data copied from the EMP table.
SELECT EMPNO , ENAME FROM EMP WHERE SAL>25000 OR DEPTNO='D1';
List all employee with their names and their salaries, whose salary lies between 25200/- and 35200/- both inclusive.
SELECT ENAME , SAL FROM EMP WHERE SAL BETWEEN 25200 AND 35200;
List the name of employees who is working at Locations (BNG,MUB,HYD) (using both OR , IN operator).
SELECT E.ENAME FROM EMP E, DEPART D WHERE E.DEPTNO=D.DNO AND LOCATION IN ('BNG','MUB','HYD');
OR---------
SELECT E.ENAME FROM EMP E, DEPART D WHERE E.DEPTNO=D.DNO
AND
(D.LOCATION='BNG' OR D.LOCATION='MUB' OR D.LOCATION='HYD');
Display department number from the table EMP avoiding the duplicated values.
SELECT DISTINCT DEPTNO FROM EMP;
Display the records in the EMP table in the ascending order of Deptno and descending order of salary
SELECT DEPTNO , SAL FROM EMP ORDER BY DEPTNO , SAL DESC;
Create a table Manager with columns Empno, Ename, Job, Deptno, Salary with structure and data copied from the EMP table.
INSERT INTO MANAGER
SELECT EMPNO, ENAME, JOB, DEPTNO, SAL FROM EMP;
List the Project Number, Project Name of all the projects handled by the department D2 and having project credits more than 5.
SELECT PRJ_NO, PRJ_NAME FROM PROJ WHERE DNO='D2' AND PRJ_CREDIT>5;
List all employees reporting to manager with empno 111.
SELECT EMPNO ,ENAME FROM EMP WHERE MGRID=111;
List all employees whose name starts with either M or R and name length is 6.
SELECT ENAME FROM EMP WHERE (ENAME LIKE 'M%' OR ENAME LIKE 'R%') AND LENGTH (ENAME)=6;
List the name of employees whose name do not start with S.
SELECT ENAME FROM EMP WHERE ENAME NOT LIKE 'S%'
Display name of employees whose 2nd & 3rd character is ‘av’ and ends with ’j’.
SELECT ENAME FROM EMP WHERE ENAME LIKE '_AV%J';
Display department number from the table EMP avoiding the duplicated values.
SELECT EMPNO , ENAME FROM EMP WHERE COMM IS NULL;
Comments
Post a Comment