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)
4 views
DBMS LAB ASSIGNMENT 6
Uploaded by
Sagar Singh
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 now
Download
Save DBMS LAB ASSIGNMENT 6 For Later
Download
Save
Save DBMS LAB ASSIGNMENT 6 For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
0 ratings
0% found this document useful (0 votes)
4 views
DBMS LAB ASSIGNMENT 6
Uploaded by
Sagar Singh
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 now
Download
Save DBMS LAB ASSIGNMENT 6 For Later
Carousel Previous
Carousel Next
Save
Save DBMS LAB ASSIGNMENT 6 For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
Download now
Download
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)
Empnum Empname Dept - Id: 'Yet To Assigned'
PDF
No ratings yet
Empnum Empname Dept - Id: 'Yet To Assigned'
3 pages
ANSYS APDL Harmonic Analysis Example
PDF
No ratings yet
ANSYS APDL Harmonic Analysis Example
23 pages
Lab-Sheets: ET 792 Two-Shaft Gas Turbine / Jet Engine
PDF
No ratings yet
Lab-Sheets: ET 792 Two-Shaft Gas Turbine / Jet Engine
13 pages
QB-Electrician Domestic Solutions Question Bank
PDF
100% (2)
QB-Electrician Domestic Solutions Question Bank
15 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
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
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
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
p3[1]
PDF
No ratings yet
p3[1]
12 pages
assignment-1 dbms
PDF
No ratings yet
assignment-1 dbms
3 pages
Name: Siva 19BCE1582 Ex. 2 DML
PDF
No ratings yet
Name: Siva 19BCE1582 Ex. 2 DML
6 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
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
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
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
HR Schema Queries - Ans
PDF
No ratings yet
HR Schema Queries - Ans
12 pages
21 SQL Assignment - 717430
PDF
No ratings yet
21 SQL Assignment - 717430
8 pages
SQL Case Study 2
PDF
No ratings yet
SQL Case Study 2
17 pages
SQL Commands
PDF
No ratings yet
SQL Commands
7 pages
VL2023240101055 Ast01
PDF
No ratings yet
VL2023240101055 Ast01
9 pages
Dbms Questions 2
PDF
No ratings yet
Dbms Questions 2
7 pages
Files 3 2022 March NotesHubDocument 1647680510
PDF
No ratings yet
Files 3 2022 March NotesHubDocument 1647680510
8 pages
Fallsem2021-22 CBS1007 Ela VL2021220104397 Reference Material Cycle Sheet 4
PDF
No ratings yet
Fallsem2021-22 CBS1007 Ela VL2021220104397 Reference Material Cycle Sheet 4
12 pages
Sem 3: DBMS Practical File
PDF
0% (1)
Sem 3: DBMS Practical File
34 pages
Let's Play with Excel
From Everand
Let's Play with Excel
Anurag Pandey
No ratings yet
dac 2
PDF
No ratings yet
dac 2
2 pages
phishing_extension_ppt _
PDF
No ratings yet
phishing_extension_ppt _
6 pages
ab5
PDF
No ratings yet
ab5
5 pages
West Sample Question
PDF
100% (1)
West Sample Question
5 pages
Thermodynamics Part 4 - Entropy
PDF
No ratings yet
Thermodynamics Part 4 - Entropy
26 pages
IGO - A318 - A319 - A320 - A321 - AMM - FSN - 352 - 01-May-2024 - 05-51-11-200-00
PDF
No ratings yet
IGO - A318 - A319 - A320 - A321 - AMM - FSN - 352 - 01-May-2024 - 05-51-11-200-00
79 pages
Wavelet Estimation MVDB
PDF
No ratings yet
Wavelet Estimation MVDB
13 pages
1.center of Percussion of A Compound Pendulum
PDF
0% (1)
1.center of Percussion of A Compound Pendulum
4 pages
PDF Simple Solutions to Energy Calculations 6th Edition Vaillencourt download
PDF
100% (3)
PDF Simple Solutions to Energy Calculations 6th Edition Vaillencourt download
65 pages
Ship - 03 - Ahts
PDF
No ratings yet
Ship - 03 - Ahts
2 pages
Bona Product Catalogue 2010
PDF
No ratings yet
Bona Product Catalogue 2010
124 pages
Fuel Systems Gasoline: Created by Mahmoud Khairy
PDF
No ratings yet
Fuel Systems Gasoline: Created by Mahmoud Khairy
13 pages
DDP Prithla 2021 Exp Note
PDF
No ratings yet
DDP Prithla 2021 Exp Note
22 pages
Form Login
PDF
No ratings yet
Form Login
8 pages
.Cease Fire Safety Quotation - Docx Image Filling
PDF
No ratings yet
.Cease Fire Safety Quotation - Docx Image Filling
7 pages
Re 120gr
PDF
No ratings yet
Re 120gr
1 page
General Description Product Summary: 250V, 14A N-Channel MOSFET
PDF
No ratings yet
General Description Product Summary: 250V, 14A N-Channel MOSFET
6 pages
EZ Professional Courses
PDF
No ratings yet
EZ Professional Courses
9 pages
Sludge Pollutants
PDF
No ratings yet
Sludge Pollutants
273 pages
Warehouse DBR 29-07-2020
PDF
No ratings yet
Warehouse DBR 29-07-2020
6 pages
Research On Limestone Calcined Clay Cement-Based Ultra-High Performance Concrete With High Cement Substitution
PDF
No ratings yet
Research On Limestone Calcined Clay Cement-Based Ultra-High Performance Concrete With High Cement Substitution
13 pages
119ar0009, Bhaskara Rao - Interior Design, Assignment-2
PDF
No ratings yet
119ar0009, Bhaskara Rao - Interior Design, Assignment-2
16 pages
Desain Lifetime Anode
PDF
No ratings yet
Desain Lifetime Anode
4 pages
2019 01 Baguio Learning Resource Module English Template
PDF
No ratings yet
2019 01 Baguio Learning Resource Module English Template
17 pages
GOODSQL
PDF
No ratings yet
GOODSQL
99 pages
CASE STUDY Mechatronics
PDF
No ratings yet
CASE STUDY Mechatronics
14 pages
Debre Tabor University Faculty of Technology, Department of Mechanical Engineering
PDF
100% (1)
Debre Tabor University Faculty of Technology, Department of Mechanical Engineering
3 pages
Process Modeling Using HYSYS With Refinery Focus
PDF
100% (3)
Process Modeling Using HYSYS With Refinery Focus
202 pages
Temperature Lockout
PDF
No ratings yet
Temperature Lockout
2 pages
LM386 Is A Low Voltage Audio Amplifier and Frequently Used in Battery Powered
PDF
No ratings yet
LM386 Is A Low Voltage Audio Amplifier and Frequently Used in Battery Powered
10 pages
Group 4 Disassembly and Assembly: 1. Brake Pump
PDF
No ratings yet
Group 4 Disassembly and Assembly: 1. Brake Pump
6 pages