0% found this document useful (0 votes)
167 views5 pages

Rajshahi University of Engineering & Technology: Lab Report

The lab report summarizes tasks completed on the instructor database including: 1) creating a table and inserting records, 2) finding average salaries for departments, 3) aggregating data like average salary, distinct IDs, and total salary by department, 4) filtering departments by average salary above 42000, and 5) conducting a self-join to find instructors who earn more than those in the Biology department. The tasks were completed successfully without errors.

Uploaded by

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

Rajshahi University of Engineering & Technology: Lab Report

The lab report summarizes tasks completed on the instructor database including: 1) creating a table and inserting records, 2) finding average salaries for departments, 3) aggregating data like average salary, distinct IDs, and total salary by department, 4) filtering departments by average salary above 42000, and 5) conducting a self-join to find instructors who earn more than those in the Biology department. The tasks were completed successfully without errors.

Uploaded by

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

Rajshahi University of Engineering & Technology

Lab Report

Course No.: CSE 3102


Course Name: Sessional based on CSE 3101
Title: Lab Task -3

Submitted To:
Dr. Md. Ali Hossain
Associate Professor
Department of Computer Science and Engineering

Submitted By:
Audity Ghosh
Roll: 1703001 Section: A
Department of Computer Science and Engineering

Date of submission: 14/03/2021


Lab Task: 3
Introduction to the problem:

Database schema:
 instructor(ID:varchar(7),name:varchar(20) , dept_name: varchar(20), salary: decimal(8,2))

The report contains the demonstration of the following tasks;


1. Create the table with the appropriate integrity constraints, insert around 10 records in the
table.
2. Determine the average salary of the instructors from “Comp. Sci. “ department.
3. Determine the average salary, distinct id, total salary of the instructors from each
department.
4. Determine the average salary of the instructors from each department having avg salary
>=42000
5. Conduct self-join operation.
Problem Statement:
We have to build one table and conduct necessary SQL commands.
Designed Database:

Table 3.0 : instructor


Submitted Query:
Query: 1 (Average Salary of instructors from “Comp. Sci. “ department)
SELECT AVG (salary) as avg_salary FROM instructor WHERE department=”Comp. Sci.”

Table: 3.1

Query:2(Average salary of instructors from each department)

SELECT department, AVG(salary) as avg_salary from instructor GROUP BY department

Table: 3.2
Query: 3 (Distinct ID, total and average salary of instructors from each department)
SELECT department,COUNT(DISTINCT ID) as Faculty_Members, SUM(salary) as
total_salary,AVG(salary) as avg_salary FROM instructor GROUP BY department

Table: 3.3

Query:4(Average salary of instructors from each department having average salary greater than
42000)

SELECT department, AVG(salary) as avg_salary from instructor GROUP BY department


HAVING AVG(salary) >=42000

Table: 3.4
Query: 5 (Print the name and salary of instructors whose salary is greater than at least one
instructor from “Biology” department.)
SELECT DISTINCT T.name, T.salary
from instructor as T, instructor as S
WHERE T.salary>S.salary AND department = ‘Biology’

Table: 3.5

Output:
Aggregate functions were implemented and ‘GROUP BY” query was implemented with
‘HAVING’ clause and ‘self-join’ was implemented.

Conclusion:
The tasks were completed and the queries contained no errors.

You might also like