Professional Documents
Culture Documents
SQL Queries For Class XII
SQL Queries For Class XII
1. Write a query to create Table EMP with columns EMPNO, ENAME, SAL, DESG, HIREDATE, DEPTNO, COMM
CREATE TABLE EMP (EMPNO NUMBER PRIMARY KEY, ENAME CHAR(20) NOT NULL, SAL NUMBER CHECK (SAL>5000), DESG CHAR(10), HIREDATE DATE, DEPTNO NUMBER, COMM NUMBER );
3. Write a query to display only those rows whose sal is between 5500 to 7000.
4. Write a query to display only those rows from emp whose name starts with A.
SELECT * FROM EMP WHERE NAME LIKE A%; Write a query to display all detals in ascending order of Sal field and descending order of DEPTNO. SELECT * FROM EMP ORDER BY SAL, DEPTNO DESC;
6. Write a query to update the details of table Emp by increasing the salary of each one by 15% whose commission is not given.
UPDATE TABLE EMP SET SAL = SAL + (0.15*SAL) WHERE COMM IS NULL;
7. Write a query to create a view from table EMP which stores all the details whose JOB
type is Manager.
9. Write a query to Delete a row from table EMP whose deptno is 40.
12. Write a query to display Deptno wise Maximum and Minimum Salary from table EMP.
13. Write a query to display details of employees by DEPTNO , TOTAL NUM OF EMP, TOTAL SAL, AVERAGE SAL from table EMP whose COMM amount is given.
SELECT DEPTNO, COUNT(*), SUM(SAL), AVG(SAL) FROM EMP GROUP BY DEPTNO HAVING COMM NOT NULL;
14. Write a query to display all details whose job type is either CLERK, MANAGER or ANALYST.