0% found this document useful (0 votes)
15 views4 pages

Final Assignment (2) Muhammad Uzair Class No (260) Section (E) Reg No (39626) Database Administration

Uploaded by

Muhammad Uzair
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views4 pages

Final Assignment (2) Muhammad Uzair Class No (260) Section (E) Reg No (39626) Database Administration

Uploaded by

Muhammad Uzair
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Final Assignment No: 2

Submitted By : Muhammmad Uzair

Submitted To : mam. Misbah daud

Class No : 260

Section : (E)

Subject : database administration

Department : IBMS

Discipline : (BSCS)
THE UNIVERSITY OF AGRICULTURE
PESHAWAR PAKISTAN

Q1: Write the sql commands for the following:


Question 1
Print average Salary of all employees from EMPLOYEE table.
SELECT AVG(SALARY) FROM employee;
Question 2
Print total Salary of all employees from EMPLOYEE table..
SELECT SUM(SALARY) FROM employee;
Question 3
Display number of employees work in each Department from EMPLOYEE Table.
SELECT department,COUNT(*) FROM employee GROUP BY department;
Question 4
Display all the Name of student ending with ‘s’ from the STUDENT tables.
SELECT * FROM student where Name like( '%s');

Question 5
Display total number of records in attribute(Emp_Name) from EMPLOYEE table.
SELECT COUNT(Emp_Name) FROM employee;
Question 6
Display “Name” column from EMPLOYEE table in upper case.
SELECT UPPER(Name) AS Uppercase Name FROM employee;
Question 7
Select distinct DEPARTMENT from EMPLOYEE table.
SELECT distinct(DEPARTMENT) FROM employee;
Question 8
Print the FIRST_NAME from Worker table after replacing ‘a’ with ‘all’.
SELECT Name,REPLACE(Name,’a’,’all’) FIRST_NAME FROM worker;
Question 9
Add CHECK constraint on Gender column using ALTER command.
ALTER table student add constraint chk check(gender in ‘male’,’female’));

Question 10
Select the Departments that have total employee number is 5.
SELECT department COUNT(*) as ‘number of employee’=5;
Question 11
Write an SQL query to show all departments along with the number of people in there.
COUNT([ALL | DISTINCT] department);
Question 12
Display the name of Students in descending order from STUDENT table.
SELECT Name FROM student order by name DESC;
Question 13
Using create command copy STUDENT Table into NEW_Student Table
CREATE table NEW_student as(SELECT*FROM student);
Question 14
Using Alter command add two columns Age and Course to table Student.
ALTER table student add age int,course varchar(20);
Question 15
Using Alter command DROP column Course from table STUDENT
ALTER table student drop column course;
Question 16
Using ALTER command add a primary key for Student_id in STUDENT table.
ALTER table student add student_id primary key;
Question 17
Display list of Employees form EMPLOYEE table whose SALARY is 100000, 5000, and
4000.
SELECT* FROM employee where salary in(100000,5000,4000);
Question 18
Write a full join query for EMPLOYEE and DEPARTMENT table (d.id=emp.did)
SELECT* FROM employee full outer join department on employee emp.id=department d.id

Question 19
Write a query that select all data from EMPLOYEE and DEPARTMENT tables
simultaneously.
SELECT* FROM employee, department;
Question 20
RENAME A TABLE STUDENT TO NEW_STUDENT.
RENAME TABLE STUDENT, NEW_STUDENT

You might also like