0% found this document useful (0 votes)
16 views

2DG1 AniagJohnRay Act2

This document contains the SQL code to create a database called AniagJohnRaySQL with two tables - College and Faculty. Data is inserted into these tables, including college codes/names and faculty details like name, rank, salary etc. A number of SELECT queries are then written to retrieve filtered data from the Faculty table based on columns like position, college, salary range, rank etc.

Uploaded by

John Ray Aniag
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)
16 views

2DG1 AniagJohnRay Act2

This document contains the SQL code to create a database called AniagJohnRaySQL with two tables - College and Faculty. Data is inserted into these tables, including college codes/names and faculty details like name, rank, salary etc. A number of SELECT queries are then written to retrieve filtered data from the Faculty table based on columns like position, college, salary range, rank etc.

Uploaded by

John Ray Aniag
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/ 2

Name: Aniag, JohnRay T.

BSIT 2DG1

--1--
create database AniagJohnRaySQL

use AniagJohnRaySQL

create table College(


CollegeCode varchar(10) constraint prim_key primary key,
CollegeName varchar(50) not null
)

create table Faculty (


EmpID int constraint empid_pk primary key,
FirstName varchar(50) not null,
MiddleName varchar(50),
LastName varchar(50) not null,
Bdate datetime,
EmpRank varchar(50),
Position varchar(20),
EmploymentStatus varchar(50),
HireDate datetime,
Salary decimal(10, 2),
RATA decimal(10, 2),
SupervisorID int constraint ssub_forkey references Faculty(EmpId),
ColCode varchar(10) constraint csub_forkey references College(CollegeCode)
)

--4--
insert into College
values ('CAL', 'College of Arts & Letters'),
('CICT', 'College of Information & Communication Technology'),
('CIT', 'College of Industrial Technology'),
('COE', 'College of Engineering'),
('CON', 'College of Nursing')

insert into Faculty


values (100, 'Keno', 'C', 'Piad', '1985-05-04', 'Professor II', 'Dean', 'R', '2010-05-
06', 98000.00, 15000.00, NULL, 'CICT'),
(101, 'Digna', 'S', 'Evale', '1980-06-25', 'Professor V', 'College Secretary', 'R',
'2000-06-06', 122000.00, 10000.00, 100, 'CICT'),
(102, 'Rose', 'C', 'Mendoza', '1980-05-25', 'Professor II', 'Department Head', 'R',
'2001-06-10', 102000.00, 10000.00, 100, 'CICT'),
(103, 'Ana', 'S', 'Cruz', '1989-05-25', 'Associate Professor III', 'Dean', 'R', '2010-
02-10', 54000.00, 15000.00, NULL, 'CON'),
(104, 'John', 'C', 'De Vera', '1995-08-04', 'Instructor III', 'Faculty', 'R', '2011-03-
15', 38000.00, NULL, 104, 'CON'),
(105, 'Melanie', 'P', 'Santos', '1981-03-28', 'Associate Professor II', 'Department
Head', 'R', '2001-06-10', 54000.00, NULL, 103, 'CICT'),
(107, 'Rina', 'C', 'Delos Reyes', '1980-08-25', 'Professor III', 'Dean', 'R', '2002-10-
02', 112000.00, 10000.00, NULL, 'COE'),
(109, 'Robert', 'C', 'Gonzales', '1990-05-21', 'Instructor I', 'Faculty', 'C', '2015-06-
10', 22000.00, NULL, 103, 'CON'),
(110, 'Gabriel', 'C', 'Canlas', '1994-04-23', 'Instructor II', 'Faculty', 'R', '2007-06-
10', 32000.00, NULL, 107, 'COE'),
(111, 'Jay', 'P', 'Zamora', '1991-02-25', 'Assistant Professor', 'Faculty', 'C', '2001-
06-10', 42000.00, NULL, 107, 'COE')

--5a--
select FirstName, LastName, Position from Faculty
--5b--
select Position+' ' +FirstName+' ' +LastName as "List of Deans" from Faculty
--5c--
select FirstName, LastName, Salary * 0.25 as "TAX" from Faculty
--5d--
select FirstName, LastName, Salary - (Salary *0.25) as "Deducted by TAX " from Faculty
--5e--
select FirstName,ColCode LastName from Faculty where ColCode = 'CON'
--5f--
select FirstName+' '+MiddleName+' '+LastName+'is holding position '+ EmpRank as "Name of
Faculty and their Rank"
from Faculty
order by LastName
--5g--
select FirstName+' '+MiddleName+' '+LastName+'is holding position '+ EmpRank as "Name of
Faculty and their Rank"
from Faculty
where EmpRank like '%Professor%'
order by LastName
--5h--
select FirstName, MiddleName, Lastname, ColCode, Salary from Faculty
where Salary >00000 and ColCode ='CICT'
--5i--
select FirstName, MiddleName, LastName, ColCode, EmpRank from Faculty
where ColCode between 'COE' and 'CON' and RATA is not null
--5j--
select FirstName, LastName, EmpRank from Faculty
where ColCode = 'CICT' and HireDate between '01-01-2000' and '12-31-2005'

You might also like