Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
32 views
4 pages
DBMS Lab Assignment 6
Uploaded by
Sagar Singh
AI-enhanced title
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
Download
Save
Save DBMS LAB ASSIGNMENT 6 For Later
Share
0%
0% found this document useful, undefined
0%
, undefined
Print
Embed
Report
0 ratings
0% found this document useful (0 votes)
32 views
4 pages
DBMS Lab Assignment 6
Uploaded by
Sagar Singh
AI-enhanced title
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
Carousel Previous
Carousel Next
Download
Save
Save DBMS LAB ASSIGNMENT 6 For Later
Share
0%
0% found this document useful, undefined
0%
, undefined
Print
Embed
Report
Download
Save DBMS LAB ASSIGNMENT 6 For Later
You are on page 1
/ 4
Search
Fullscreen
1.
Create an Employee table with the following attributes:
EmployeeID – Primary Key
FirstName – Not Null Constraint
LastName – Not Null Constraint
Gender – Check Constraint Values (‘M’, ‘F’)
BirthDate – Not Null Constraint
HireDate – Not Null Constraint
Salary – Check Constraint (Salary >0)
Email – Unique and Not null constraint
PhoneNumber – Not NUll
Department – Check Constraint ('HR', 'IT', 'Finance', 'Sales',
'Marketing')
ManagerID – Self referencing Foreign Key
IsFullTime – Boolean Data type (Default value is True)
CREATE TABLE Employee
(EmployeeID INT PRIMARY KEY,
FirstName VARCHAR(50) NOT NULL,
LastName VARCHAR(50) NOT NULL,
Gender CHAR(1) CHECK (Gender IN ('M', 'F')),
BirthDate DATE NOT NULL,
HireDate DATE NOT NULL,
Salary DECIMAL(10, 2) CHECK (Salary > 0),
Email VARCHAR(100) UNIQUE NOT NULL,
PhoneNumber Numeric(15) Not NUll,
Department VARCHAR(50) CHECK (Department IN ('HR', 'IT', 'Finance',
'Sales', 'Marketing')),
ManagerID INT,
IsFullTime BOOLEAN DEFAULT TRUE,
FOREIGN KEY (ManagerID) REFERENCES Employee(EmployeeID));
2. Insert 15 rows into the Employee table
INSERT INTO Employee (EmployeeID, FirstName, LastName, Gender,
BirthDate, HireDate, Salary, Email, PhoneNumber, Department, ManagerID,
IsFullTime) VALUES
(1, 'Alice', 'Smith', 'F', '1990-01-15', '2020-02-20', 60000.00,
'
[email protected]
', '1234567890', 'HR', NULL, TRUE),
(2, 'Bob', 'Johnson', 'M', '1985-05-25', '2019-03-10', 70000.00,
'
[email protected]
', '1234567891', 'IT', 1, TRUE),
(3, 'Carol', 'Williams', 'F', '1992-07-30', '2021-08-15', 55000.00,
'
[email protected]
', '1234567892', 'Finance', 1, TRUE),
(4, 'David', 'Brown', 'M', '1988-12-05', '2018-01-25', 80000.00,
'
[email protected]
', '1234567893', 'Sales', 2, TRUE),
(5, 'Eve', 'Jones', 'F', '1995-03-14', '2022-06-30', 45000.00,
'
[email protected]
', '1234567894', 'Marketing', 3, TRUE),
(6, 'Frank', 'Garcia', 'M', '1987-04-18', '2020-11-01', 62000.00,
'
[email protected]
', '1234567895', 'IT', 2, TRUE),
(7, 'Grace', 'Martinez', 'F', '1993-10-09', '2021-05-17', 48000.00,
'
[email protected]
', '1234567896', 'Finance', 3, TRUE),
(8, 'Henry', 'Hernandez', 'M', '1980-09-21', '2017-04-12', 75000.00,
'
[email protected]
', '1234567897', 'Sales', 4, TRUE),
(9, 'Ivy', 'Lopez', 'F', '1994-02-11', '2022-09-05', 52000.00,
'
[email protected]
', '1234567898', 'Marketing', 5, TRUE),
(10, 'Jack', 'Wilson', 'M', '1986-06-16', '2019-12-22', 72000.00,
'
[email protected]
', '1234567899', 'HR', 1, TRUE),
(11, 'Karen', 'Anderson', 'F', '1991-08-30', '2021-03-08', 61000.00,
'
[email protected]
', '1234567800', 'IT', 2, TRUE),
(12, 'Larry', 'Thomas', 'M', '1984-11-03', '2018-07-19', 82000.00,
'
[email protected]
', '1234567801', 'Finance', 3, TRUE),
(13, 'Megan', 'Taylor', 'F', '1990-03-29', '2020-10-29', 53000.00,
'
[email protected]
', '1234567802', 'Sales', 4, TRUE),
(14, 'Nina', 'Moore', 'F', '1996-05-12', '2022-02-17', 49000.00,
'
[email protected]
', '1234567803', 'Marketing', 5, TRUE),
(15, 'Oscar', 'Jackson', 'M', '1989-07-07', '2018-11-11', 74000.00,
'
[email protected]
', '1234567804', 'HR', 10, TRUE);
3. Count the number of Employees in each department.
SELECT Department, COUNT(*) AS EmployeeCount FROM Employee GROUP
BY Department HAVING COUNT(*) > 1;
4. Display the Average salary based on gender if average
salary is greater than 50000.
SELECT Gender, AVG(Salary) AS AverageSalary FROM Employee GROUP BY
Gender HAVING AVG(Salary) > 50000;
5. Display the total salary expenditure for each department.
SELECT Department, SUM(Salary) AS TotalSalary FROM Employee GROUP BY Department HAVING
SUM(Salary) > 100000;
6. Display the department where maximum salary is less than
80000.
SELECT Department, MAX(Salary) AS MaxSalary FROM Employee GROUP
BY Department HAVING MAX(Salary) < 80000;
7. Display the department details where the number of
employee is greater than 2 and all employees are full time
employee.
SELECT Department, COUNT(*) AS FullTimeCount FROM Employee
WHERE IsFullTime = TRUE GROUP BY Department HAVING COUNT(*) > 2;
8. Find Employees Who Have a Phone Number That Starts with
'123'
SELECT EmployeeID, FirstName, LastName, PhoneNumber FROM Employee
WHERE PhoneNumber LIKE '123%';
9. Add a Bonus to Each Employee's Salary (10% increase).
SELECT EmployeeID, FirstName, LastName, Salary, Salary * 1.10 AS
SalaryWithBonus FROM Employee;
10. Convert Employee First Name to Uppercase
SELECT EmployeeID, UPPER(FirstName) AS FirstName_Upper, LastName
FROM Employee;
11. Get the Length of Each Employee's Full Name (FirstName +
LastName)
SELECT EmployeeID, FirstName, LastName, LENGTH(FirstName) +
LENGTH(LastName) AS FullNameLength FROM Employee;
12. Round the Salaries to the Nearest Thousand
SELECT EmployeeID, FirstName, LastName, Salary, ROUND(Salary, -3) AS
RoundedSalary FROM Employee;
You might also like
Pay Matters: The Art and Science of Employee Compensation
From Everand
Pay Matters: The Art and Science of Employee Compensation
David Weaver
5/5 (1)
20 SQL Exercises For Practice: Table Structure and Schema
PDF
100% (5)
20 SQL Exercises For Practice: Table Structure and Schema
12 pages
SQL Queries: 200+ Queries to Challenge you.
From Everand
SQL Queries: 200+ Queries to Challenge you.
Swaroop Kallakuri
5/5 (2)
Esp32 Technical Reference Manual en
PDF
No ratings yet
Esp32 Technical Reference Manual en
660 pages
Fundamentals of Meter Provers and Proving Methods
PDF
100% (1)
Fundamentals of Meter Provers and Proving Methods
9 pages
Mircoproject Queries
PDF
No ratings yet
Mircoproject Queries
9 pages
Mysql Practice
PDF
No ratings yet
Mysql Practice
10 pages
Lab Answers
PDF
No ratings yet
Lab Answers
21 pages
Database Programming Evaluation Practical
PDF
No ratings yet
Database Programming Evaluation Practical
10 pages
3rd Company
PDF
No ratings yet
3rd Company
2 pages
RDBMS1
PDF
No ratings yet
RDBMS1
7 pages
Lab Objectives
PDF
No ratings yet
Lab Objectives
6 pages
Assignment 3 - Shouvik (1159)
PDF
No ratings yet
Assignment 3 - Shouvik (1159)
15 pages
Untitled Document
PDF
No ratings yet
Untitled Document
5 pages
SQL Exercises and Solutions in MySQL
PDF
No ratings yet
SQL Exercises and Solutions in MySQL
12 pages
SQL Exercises and Solutions in MySQL Practice
PDF
No ratings yet
SQL Exercises and Solutions in MySQL Practice
10 pages
SQL 3
PDF
0% (1)
SQL 3
7 pages
DBMS Record Lab Manual
PDF
100% (1)
DBMS Record Lab Manual
23 pages
DBMS All PR
PDF
No ratings yet
DBMS All PR
13 pages
Additional SQL Queries For Practice
PDF
No ratings yet
Additional SQL Queries For Practice
6 pages
SCHEMA1
PDF
No ratings yet
SCHEMA1
19 pages
Abhay 51048 Dbms Ass 04
PDF
No ratings yet
Abhay 51048 Dbms Ass 04
8 pages
SQL New Assignment 2
PDF
No ratings yet
SQL New Assignment 2
5 pages
Mysql Practical File Assignment
PDF
No ratings yet
Mysql Practical File Assignment
6 pages
Dbms Lab1
PDF
No ratings yet
Dbms Lab1
14 pages
Source Code Dbms
PDF
No ratings yet
Source Code Dbms
14 pages
MST - Database Management System Lab Worksheet - 1
PDF
No ratings yet
MST - Database Management System Lab Worksheet - 1
4 pages
Lab 2&3
PDF
No ratings yet
Lab 2&3
3 pages
SQL A
PDF
No ratings yet
SQL A
5 pages
How Many Different Departments Are There in The Employee' Table. A)
PDF
No ratings yet
How Many Different Departments Are There in The Employee' Table. A)
14 pages
18bit0166 Ayush Kanaujia
PDF
No ratings yet
18bit0166 Ayush Kanaujia
12 pages
Tabele Do Ćwiczeń
PDF
No ratings yet
Tabele Do Ćwiczeń
4 pages
21bce0968 VL2023240100969 Ast02
PDF
No ratings yet
21bce0968 VL2023240100969 Ast02
20 pages
Institute of Technology, Nirma University Semester III Course Code & Name: Report On Topic: Prepared & Submitted by
PDF
No ratings yet
Institute of Technology, Nirma University Semester III Course Code & Name: Report On Topic: Prepared & Submitted by
12 pages
Assignment-1 Dbms
PDF
No ratings yet
Assignment-1 Dbms
3 pages
Case When Coding Snippet
PDF
No ratings yet
Case When Coding Snippet
20 pages
Name: Siva 19BCE1582 Ex. 2 DML
PDF
No ratings yet
Name: Siva 19BCE1582 Ex. 2 DML
6 pages
18apr2025 Nasim
PDF
No ratings yet
18apr2025 Nasim
4 pages
Challenge Transactions
PDF
No ratings yet
Challenge Transactions
2 pages
Dac DBT SQL Exercises and Solutions Assignments III IV V
PDF
100% (2)
Dac DBT SQL Exercises and Solutions Assignments III IV V
10 pages
DBMS Lab Practical 1
PDF
No ratings yet
DBMS Lab Practical 1
4 pages
Name: Roll # Class ID: 103752
PDF
No ratings yet
Name: Roll # Class ID: 103752
5 pages
Sanjar Xolmirzayev - SQL Practice Worksheet (Employee Database)
PDF
No ratings yet
Sanjar Xolmirzayev - SQL Practice Worksheet (Employee Database)
9 pages
HMT 3072 SQL PDF
PDF
No ratings yet
HMT 3072 SQL PDF
58 pages
SQL HR Case Study
PDF
No ratings yet
SQL HR Case Study
6 pages
DBMS 5Q
PDF
No ratings yet
DBMS 5Q
10 pages
Practice Questions
PDF
No ratings yet
Practice Questions
8 pages
Tables For Practice
PDF
No ratings yet
Tables For Practice
5 pages
Cep 1 Employee Performance Mapping Problem Statment
PDF
No ratings yet
Cep 1 Employee Performance Mapping Problem Statment
10 pages
HR Schema
PDF
No ratings yet
HR Schema
18 pages
SQL Interview Questions Top 100
PDF
No ratings yet
SQL Interview Questions Top 100
18 pages
DBMS Practical
PDF
No ratings yet
DBMS Practical
6 pages
Dbms Assin 1
PDF
No ratings yet
Dbms Assin 1
29 pages
Daily Practice Questions
PDF
No ratings yet
Daily Practice Questions
2 pages
LiveSQL 1
PDF
No ratings yet
LiveSQL 1
2 pages
Lab 3 - Aliases TO Truncate
PDF
No ratings yet
Lab 3 - Aliases TO Truncate
9 pages
Project
PDF
No ratings yet
Project
16 pages
Empnum Empname Dept - Id: 'Yet To Assigned'
PDF
No ratings yet
Empnum Empname Dept - Id: 'Yet To Assigned'
3 pages
Exercise 1
PDF
No ratings yet
Exercise 1
2 pages
DBMS Lab
PDF
No ratings yet
DBMS Lab
15 pages
Lab 3
PDF
No ratings yet
Lab 3
2 pages
Let's Play with Excel
From Everand
Let's Play with Excel
Anurag Pandey
No ratings yet
Must Upload at Least One Useful Note PDF (Not Among The Top 50 Common Ones) Access or Search Others' Notes
PDF
No ratings yet
Must Upload at Least One Useful Note PDF (Not Among The Top 50 Common Ones) Access or Search Others' Notes
3 pages
Dac 2
PDF
No ratings yet
Dac 2
2 pages
Phishing - Extension - PPT
PDF
No ratings yet
Phishing - Extension - PPT
6 pages
Ab 5
PDF
No ratings yet
Ab 5
5 pages
West Sample Question
PDF
100% (1)
West Sample Question
5 pages
Rotary Screw Compressors
PDF
100% (4)
Rotary Screw Compressors
22 pages
Exposing The Deception Deepfake Detection
PDF
No ratings yet
Exposing The Deception Deepfake Detection
13 pages
Valsir - Triplus New
PDF
No ratings yet
Valsir - Triplus New
20 pages
Level Iii Ut Specific Examination
PDF
No ratings yet
Level Iii Ut Specific Examination
8 pages
Ip Study Material
PDF
No ratings yet
Ip Study Material
185 pages
Explosive Detection Systems For Cabin Baggage Edscb Excel Format
PDF
No ratings yet
Explosive Detection Systems For Cabin Baggage Edscb Excel Format
3 pages
Economic Order Quantity: Information
PDF
No ratings yet
Economic Order Quantity: Information
11 pages
Kubernetes Container
PDF
No ratings yet
Kubernetes Container
7 pages
Capacity Design
PDF
No ratings yet
Capacity Design
12 pages
(Reg. Relationship Steps
PDF
No ratings yet
(Reg. Relationship Steps
4 pages
Application of Matrix - Linear Mapping-5
PDF
No ratings yet
Application of Matrix - Linear Mapping-5
7 pages
A Review On Cellular Manufacturing Syste
PDF
No ratings yet
A Review On Cellular Manufacturing Syste
5 pages
Repeatability & Reproducibility of Determination of Nitrogen Content of Fishmeal by Combustion Dumas & Comparison With Kjeldahl
PDF
No ratings yet
Repeatability & Reproducibility of Determination of Nitrogen Content of Fishmeal by Combustion Dumas & Comparison With Kjeldahl
15 pages
Control of A Two-Tank System - MATLAB & Simulink Example PDF
PDF
No ratings yet
Control of A Two-Tank System - MATLAB & Simulink Example PDF
21 pages
Nursery - Syllabus
PDF
No ratings yet
Nursery - Syllabus
10 pages
EWP Micro Project
PDF
No ratings yet
EWP Micro Project
5 pages
Project Report
PDF
No ratings yet
Project Report
29 pages
Line Algorithm
PDF
No ratings yet
Line Algorithm
62 pages
Nastran Shell Element Orientation Question
PDF
No ratings yet
Nastran Shell Element Orientation Question
3 pages
Prajwal Deshmukh - Batch A
PDF
No ratings yet
Prajwal Deshmukh - Batch A
38 pages
ENCOR - Chapter - 1 - Packet Forwarding
PDF
No ratings yet
ENCOR - Chapter - 1 - Packet Forwarding
57 pages
CBSE Class 11 Mathematics Worksheet - Set Theory (1) Export PDF
PDF
100% (1)
CBSE Class 11 Mathematics Worksheet - Set Theory (1) Export PDF
14 pages
Flutter Analysis of The Aircraft Wing: Paramasivam Suresh (Ur13Ae044)
PDF
No ratings yet
Flutter Analysis of The Aircraft Wing: Paramasivam Suresh (Ur13Ae044)
9 pages
3500 C175 C280 AftertreatmentCEM T4 Marine A and I
PDF
100% (1)
3500 C175 C280 AftertreatmentCEM T4 Marine A and I
121 pages
Improvements in The Mechanical Properties of The 18R-6R High-Hysteresis Martensitic Transformation by Nanoprecipitates in CuZnAl Alloys
PDF
No ratings yet
Improvements in The Mechanical Properties of The 18R-6R High-Hysteresis Martensitic Transformation by Nanoprecipitates in CuZnAl Alloys
8 pages
COMP 002 Computer Application Module TEACHERS
PDF
No ratings yet
COMP 002 Computer Application Module TEACHERS
34 pages
Reteach Multiples - Worksheet Given by The Teacher
PDF
No ratings yet
Reteach Multiples - Worksheet Given by The Teacher
1 page
Iub Port Available Bandwidth Utilizing Ratio PDF
PDF
No ratings yet
Iub Port Available Bandwidth Utilizing Ratio PDF
2 pages