3
DDL Practice Questions (1-14) SQL Practice Questions 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. Display all the information of the EMP table. 2. Display unique jobs from EMP table. 3. List the details of the emps in asc order of their salaries. 4. List the details of the emps in asc order of the Deptnos and desc of Jobs. 5. Display all the unique job groups in the descending order. 6. Display all the details of all ‘Mgrs’. 7. List the emps who joined before 1981. 8. List the Empno, Ename, Sal, Daily Sal of all Employees in the ASC order of AnnSal. 9. Display the empno , ename, job, hiredate, exp of all Mgrs. 10. List the empno, ename, sal, exp of all emps working for Mgr 7839. 11. Display the details of the emps whose Comm. Is more than their sal. 12. List the emps in the asc order of Designations.

SQL Practice Questions

  • Upload
    shivuhc

  • View
    223

  • Download
    3

Embed Size (px)

DESCRIPTION

.NET

Citation preview

  • DDL Practice Questions (1-14)

    SQL Practice Questions

    1. Create Database as 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 EmpDb

    DML Practice Questions (1-50) Questions on Simple Queries 1 to 25

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

  • 13. List the emps along with their exp and daily sal is more than Rs.100. 14. List the emps with hiredate in format June 4,1988. 15. List the emps who are either CLERK or ANALYST in the desc order. 16. List the emps who joined on 1May81,31Dec81, 17Dec81, 19Jan80 in asc order of

    seniority. 17. List the emps who are working for the deptno 10 or 20. 18. List the emps who are joined in the year 1981. 19. List the emps who are joined in the month of Aug 1980. 20. List the emps whose annul sal ranging from 22000 and 45000. 21. List the emps those are having five characters in their names. 22. List the enames those are starting with s and with fire characters. 23. List the emps those are having four chars and third char must be r. 24. List the 5 character names starting with s and ending with h. 25. 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 working under Accounting & Research in the asc deptno.

    27. 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

    28. List the empno, ename, sal, dname, grade, exp, ann sal of emps working for dept 20 or 10.

    29. 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.

    30. Find out the emps who joined in the company before their managers. 31. List all the emps by name and number along with their managers name and number

    also list KING who has no Manager. 32. List the emps who are either clerks with an exp more than 8y. 33. 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. 34. List the details of the emps whose salaries more than the employee BLAKE. 35. List the details of the emps whose job is same as ALLEN.

    Questions on Sub Queries 36 to 45

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

  • 41. List the details of the emps whose grade is equal to one tenth of sales dept. 42. List the managers name who is having max no of emps working under him. 43. List the empno, ename, ann sal, daily sal of all salesman in the asc ann sal. 44. List the details of the emps whose salaries more than the employee BLAKE. 45. List the 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 names should not be either miller or allen.

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