You are on page 1of 3

SQL Practice Questions

DDL Practice Questions (1-14)


1. Create Database as <YourName>EmpDb
2. Add a Table Employees with Columns
EmpID (Primary Key) int
FirstName nvarchar(20)
LastName nvarachar(20)
Salary bigint
Hiring Date - date
Dept ID(Foreign Key) int
3. Add Table Departments with Columns DeptID and Department Name
4. Add Salary constraint as minimum salary 6000 and maximum salary 9000
5. Add a column age and add age constraints as 0 to 120.
6. Drop the age constraint
7. Add 5 Employees E1 E5
8. Add 3 Departments
9. Update E3 Salary to 25000
10. Delete Employee E4
11. Delete Column Age
12. Delete Table Departments
13. Remove Foreign Key Constraint on DeptID
14. Delete Database <YourName>EmpDb

DML Practice Questions (1-50)


Questions on Simple Queries 1 to 25

1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.

Display all the information of the EMP table.


Display unique jobs from EMP table.
List the details of the emps in asc order of their salaries.
List the details of the emps in asc order of the Deptnos and desc of Jobs.
Display all the unique job groups in the descending order.
Display all the details of all Mgrs.
List the emps who joined before 1981.
List the Empno, Ename, Sal, Daily Sal of all Employees in the ASC order of AnnSal.
Display the empno , ename, job, hiredate, exp of all Mgrs.
List the empno, ename, sal, exp of all emps working for Mgr 7839.
Display the details of the emps whose Comm. Is more than their sal.
List the emps in the asc order of Designations.

13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.

List the emps along with their exp and daily sal is more than Rs.100.
List the emps with hiredate in format June 4,1988.
List the emps who are either CLERK or ANALYST in the desc order.
List the emps who joined on 1May81,31Dec81, 17Dec81, 19Jan80 in asc order of
seniority.
List the emps who are working for the deptno 10 or 20.
List the emps who are joined in the year 1981.
List the emps who are joined in the month of Aug 1980.
List the emps whose annul sal ranging from 22000 and 45000.
List the emps those are having five characters in their names.
List the enames those are starting with s and with fire characters.
List the emps those are having four chars and third char must be r.
List the 5 character names starting with s and ending with h.
List the ename and sal is increased by 15% and expressed as no of dollars.
Questions on Joins 26 to 35

26. List the total information of emp table along with dname and loc of all the emps
27.

28.
29.

30.
31.
32.
33.
34.
35.

working under Accounting & Research in the asc deptno.


List the empno, ename, sal, dname, loc, deptno, job of all emps working at CHICAGO
or working for ACCOUNTING dept wit ann sal > 2800, but the sal should not be = 3000
or 2800
List the empno, ename, sal, dname, grade, exp, ann sal of emps working for dept 20 or
10.
List all the information of emps with loc and the grade of all the emps belong to the
grade ranges from 2 to 4 working at the dept those are not starting with char set OP
and not ending with S with the design having a char a any where joined in the year
81 but not in the month of Mar or Sep and sal not end with 00 in the asc order of
grades.
Find out the emps who joined in the company before their managers.
List all the emps by name and number along with their managers name and number
also list KING who has no Manager.
List the emps who are either clerks with an exp more than 8y.
List the empno, ename, sal, dname of all the Mgrs and Analyst working in NEWYORK,
DALLAS with an exp more than 7 years without receiving the Comma Asc order of Loc.
List the details of the emps whose salaries more than the employee BLAKE.
List the details of the emps whose job is same as ALLEN.
Questions on Sub Queries 36 to 45

36.
37.
38.
39.
40.

List the emps who are senior to King.


Display the details of most senior employee belongs to 1981.
List the emps who joined in 81 with job same as the most senior person of year 81.
List the most senior emp working under KING and Grade is more than 3.
List the emps who joined in the company on the same date.

41.
42.
43.
44.
45.

List
List
List
List
List

the
the
the
the
the

details of the emps whose grade is equal to one tenth of sales dept.
managers name who is having max no of emps working under him.
empno, ename, ann sal, daily sal of all salesman in the asc ann sal.
details of the emps whose salaries more than the employee BLAKE.
emps who are senior to their own MGRs.

Questions on Joins and Sub Queries 46 to 50

46. List the grade 3 emps of research & operations depts. Joined after 1987 and whose
47.
48.
49.
50.

names should not be either miller or allen.


List the empno, ename, loc, sal, dname,loc of all the emps belong to kings dept.
List the empno, ename, hiredate, current date & exp in the asc order of exp.
List the emps whose exp is more than 10 years
List the Mgrs of dept 10 or 20.

You might also like