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)
30 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)
30 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
20 SQL Exercises For Practice: Table Structure and Schema
PDF
100% (5)
20 SQL Exercises For Practice: Table Structure and Schema
12 pages
Associate Cloud Engineer Dump
PDF
No ratings yet
Associate Cloud Engineer Dump
6 pages
ADOP Patching Gotchas!: What Can and Will Go Wrong When Patching EBS 12.2.X and How To Fix It!
PDF
No ratings yet
ADOP Patching Gotchas!: What Can and Will Go Wrong When Patching EBS 12.2.X and How To Fix It!
41 pages
West Sample Question
PDF
100% (1)
West Sample Question
5 pages
DAMA Notes
PDF
No ratings yet
DAMA Notes
157 pages
Yiyo Jair
PDF
No ratings yet
Yiyo Jair
523 pages
Sushil Manula Testing
PDF
No ratings yet
Sushil Manula Testing
5 pages
Handout Build Scalable RAG Applications Using Amazon Bedrock Knowledge Bases
PDF
No ratings yet
Handout Build Scalable RAG Applications Using Amazon Bedrock Knowledge Bases
23 pages
Map Viewer Configuration For OBIEE 11g
PDF
100% (1)
Map Viewer Configuration For OBIEE 11g
30 pages
Dashboard Tools With Kyubit BI User Manual
PDF
No ratings yet
Dashboard Tools With Kyubit BI User Manual
143 pages
Uface 302 Manual
PDF
No ratings yet
Uface 302 Manual
75 pages
DM - MOD - 2 Part - I
PDF
No ratings yet
DM - MOD - 2 Part - I
19 pages
Log
PDF
No ratings yet
Log
35 pages
AWR
PDF
No ratings yet
AWR
8 pages
Source Code Dbms
PDF
No ratings yet
Source Code Dbms
14 pages
Eventlog
PDF
No ratings yet
Eventlog
16 pages
Sanjar Xolmirzayev - SQL Practice Worksheet (Employee Database)
PDF
No ratings yet
Sanjar Xolmirzayev - SQL Practice Worksheet (Employee Database)
9 pages
DBMS Lab Practical 1
PDF
No ratings yet
DBMS Lab Practical 1
4 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
Untitled Document
PDF
No ratings yet
Untitled Document
5 pages
SQL Exercises and Solutions in MySQL Practice
PDF
No ratings yet
SQL Exercises and Solutions in MySQL Practice
10 pages
Phishing - Extension - PPT
PDF
No ratings yet
Phishing - Extension - PPT
6 pages
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
Snapvault Best Practice PDF
PDF
No ratings yet
Snapvault Best Practice PDF
34 pages
Log
PDF
No ratings yet
Log
8 pages
Case When Coding Snippet
PDF
No ratings yet
Case When Coding Snippet
20 pages
Dac 2
PDF
No ratings yet
Dac 2
2 pages
DISCO searchQuickReference
PDF
No ratings yet
DISCO searchQuickReference
12 pages
Lab 3
PDF
No ratings yet
Lab 3
2 pages
Transportation and Logistics Data Lake Ra
PDF
No ratings yet
Transportation and Logistics Data Lake Ra
1 page
Module 1 Notes Dbms
PDF
No ratings yet
Module 1 Notes Dbms
5 pages
ETL Test Cases
PDF
No ratings yet
ETL Test Cases
14 pages
SQL Exercises and Solutions in MySQL
PDF
No ratings yet
SQL Exercises and Solutions in MySQL
12 pages
Oracle Payroll Retropay (Enhanced) - A Functional White Paper
PDF
No ratings yet
Oracle Payroll Retropay (Enhanced) - A Functional White Paper
22 pages
Exercise 1
PDF
No ratings yet
Exercise 1
2 pages
DBMS All PR
PDF
No ratings yet
DBMS All PR
13 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
SQL Recovery With Auto Snapshot Manager: Lab Exercise 4
PDF
No ratings yet
SQL Recovery With Auto Snapshot Manager: Lab Exercise 4
6 pages
DBMS 5Q
PDF
No ratings yet
DBMS 5Q
10 pages
DBMS Practical
PDF
No ratings yet
DBMS Practical
6 pages
Tabele Do Ćwiczeń
PDF
No ratings yet
Tabele Do Ćwiczeń
4 pages
Mysql Practice
PDF
No ratings yet
Mysql Practice
10 pages
DBMS Record Lab Manual
PDF
100% (1)
DBMS Record Lab Manual
23 pages
DBMS Lab
PDF
No ratings yet
DBMS Lab
15 pages
GCSE OCR 1.2 Suitable Storage Devices & Storage Media
PDF
No ratings yet
GCSE OCR 1.2 Suitable Storage Devices & Storage Media
13 pages
Lab 3 - Aliases TO Truncate
PDF
No ratings yet
Lab 3 - Aliases TO Truncate
9 pages
GG Doc
PDF
No ratings yet
GG Doc
9 pages
18apr2025 Nasim
PDF
No ratings yet
18apr2025 Nasim
4 pages
Mircoproject Queries
PDF
No ratings yet
Mircoproject Queries
9 pages
Challenge Transactions
PDF
No ratings yet
Challenge Transactions
2 pages
AWR - Automatic Workload Repository
PDF
No ratings yet
AWR - Automatic Workload Repository
19 pages
Task List For Project Management and The Professional Assignment 2 - UTS
PDF
No ratings yet
Task List For Project Management and The Professional Assignment 2 - UTS
5 pages
Daily Practice Questions
PDF
No ratings yet
Daily Practice Questions
2 pages
Lab 2&3
PDF
No ratings yet
Lab 2&3
3 pages
Assignment-1 Dbms
PDF
No ratings yet
Assignment-1 Dbms
3 pages
Dbms Assin 1
PDF
No ratings yet
Dbms Assin 1
29 pages
Ab 5
PDF
No ratings yet
Ab 5
5 pages
RDBMS1
PDF
No ratings yet
RDBMS1
7 pages
21bce0968 VL2023240100969 Ast02
PDF
No ratings yet
21bce0968 VL2023240100969 Ast02
20 pages
SQL New Assignment 2
PDF
No ratings yet
SQL New Assignment 2
5 pages
SQL A
PDF
No ratings yet
SQL A
5 pages
Lab Objectives
PDF
No ratings yet
Lab Objectives
6 pages
SQL HR Case Study
PDF
No ratings yet
SQL HR Case Study
6 pages
Name: Siva 19BCE1582 Ex. 2 DML
PDF
No ratings yet
Name: Siva 19BCE1582 Ex. 2 DML
6 pages
3rd Company
PDF
No ratings yet
3rd Company
2 pages
LiveSQL 1
PDF
No ratings yet
LiveSQL 1
2 pages
Tables For Practice
PDF
No ratings yet
Tables For Practice
5 pages
Dbms Lab1
PDF
No ratings yet
Dbms Lab1
14 pages
HMT 3072 SQL PDF
PDF
No ratings yet
HMT 3072 SQL PDF
58 pages
Database Programming Evaluation Practical
PDF
No ratings yet
Database Programming Evaluation Practical
10 pages
SCHEMA1
PDF
No ratings yet
SCHEMA1
19 pages
402 Information Tech MS X
PDF
No ratings yet
402 Information Tech MS X
9 pages
Lab Answers
PDF
No ratings yet
Lab Answers
21 pages
Abhay 51048 Dbms Ass 04
PDF
No ratings yet
Abhay 51048 Dbms Ass 04
8 pages
HR Schema
PDF
No ratings yet
HR Schema
18 pages
Assignment 3 - Shouvik (1159)
PDF
No ratings yet
Assignment 3 - Shouvik (1159)
15 pages
SQL Interview Questions Top 100
PDF
No ratings yet
SQL Interview Questions Top 100
18 pages
15CS754 SAN Solution Manual
PDF
No ratings yet
15CS754 SAN Solution Manual
15 pages
Additional SQL Queries For Practice
PDF
No ratings yet
Additional SQL Queries For Practice
6 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
Project
PDF
No ratings yet
Project
16 pages
Cep 1 Employee Performance Mapping Problem Statment
PDF
No ratings yet
Cep 1 Employee Performance Mapping Problem Statment
10 pages
MST - Database Management System Lab Worksheet - 1
PDF
No ratings yet
MST - Database Management System Lab Worksheet - 1
4 pages
Mysql Practical File Assignment
PDF
No ratings yet
Mysql Practical File Assignment
6 pages
Name: Roll # Class ID: 103752
PDF
No ratings yet
Name: Roll # Class ID: 103752
5 pages
Add Power To RPG 400 With Embedded SQL
PDF
No ratings yet
Add Power To RPG 400 With Embedded SQL
12 pages
18bit0166 Ayush Kanaujia
PDF
No ratings yet
18bit0166 Ayush Kanaujia
12 pages
Cloning Database Training
PDF
No ratings yet
Cloning Database Training
16 pages
Practice Questions
PDF
No ratings yet
Practice Questions
8 pages
Framework Manager Interview Questions
PDF
No ratings yet
Framework Manager Interview Questions
4 pages
Empnum Empname Dept - Id: 'Yet To Assigned'
PDF
No ratings yet
Empnum Empname Dept - Id: 'Yet To Assigned'
3 pages
SQL 3
PDF
0% (1)
SQL 3
7 pages