0% found this document useful (0 votes)
9 views8 pages

CS Part e

The document contains SQL commands for creating and managing tables for employee and student records, including operations such as counting, summing salaries, and calculating averages. It also includes commands for inserting, updating, and deleting records, as well as calculating financial metrics like Gross Salary and Income Tax. Additionally, it mentions class templates and K-map, suggesting a broader context of programming and data organization.

Uploaded by

justinpeter843
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)
9 views8 pages

CS Part e

The document contains SQL commands for creating and managing tables for employee and student records, including operations such as counting, summing salaries, and calculating averages. It also includes commands for inserting, updating, and deleting records, as well as calculating financial metrics like Gross Salary and Income Tax. Additionally, it mentions class templates and K-map, suggesting a broader context of programming and data organization.

Uploaded by

justinpeter843
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/ 8

ANS) Create Table:

create table employee ( Empid number(10), Name varchar2(20), Age number(10), Salary
number(10));

Display Structure:
desc employee;

Find Total Number of Employees:


select count(*) as TotalEmployees from Employee;

Find Sum of All Salaries:


select sum(Salary) as TotalSalary from Employee;

Display Employees with Age >= 15:


select * from Employee where Age >= 15;

ANS)
Create Table:
create table Student (Regno number(10), Name varchar2(20),DOB date, Marks number(10));

Find Total Number of Students:


select count(*) AS TotalStudents from Student;

Find Highest Marks:


select max(Marks) as HighestMarks from Student;
Find Lowest Marks:
select min(Marks) as LowestMarks from Student;

Display All Student Records:


select * from student;

Display All Records


select * from employee;

Find Maximum Net Salary:


select max(Net_Salary) as MaxNetSalary from Employee;

Find Minimum Net Salary:


select min(Net_Salary) as MinNetSalary from Employee;

Delete All Records:


delete from Employee;

Remove the Table:


drop table Employee;
Create Table:
create table student (regno number(10), name varchar2(20), marks number(10));

Insert Record:
insert into student values (1, 'AA', 90);
insert into student values (2, 'BB', 80);
insert into student values (3, 'CC', 70);

Recalculate Marks by Adding 5:


update student set marks = marks + 5

Display Structure:
desc student;

Display Record:
select * from student;

Create Table:
create table student (StudentNo number(10),Name varchar2(25),Sub1 number(2), Sub2
number(2),Sub3 number(2),Total number(5),Average number(4,2),Result VARCHAR(10));

Insert sample data (optional)


INSERT INTO STUDENT (StudentNo, Name, Sub1, Sub2, Sub3)
VALUES (1, 'AA', 40, 50, 30),
(2, 'BB', 20, 25, 30),
(3, 'CC', 50, 60, 70);
-- Calculate Total, Average, and Result
update student set Total = Sub1 + Sub2 + Sub3;
update student set Average = Total / 3.0;
update student set Result = 'PASS' WHERE Average >= 35;
update student set Result = 'FAIL' WHERE Average < 35;

-- Display the table with Total, Average, and Result


select StudentNo, Name, Sub1, Sub2, Sub3, Total, Average, Result from student;
OR
select * from student;

Create Table:
create table student (StudentNo number(10),Name varchar2(25),Sub1 number(2), Sub2
number(2),Sub3 number(2),Total number(5),Average number(4,2));

Insert sample data (optional)


INSERT INTO STUDENT (StudentNo, Name, Sub1, Sub2, Sub3)
VALUES (1, 'AA', 40, 50, 30),
(2, 'BB', 20, 25, 30),
(3, 'CC', 50, 60, 70);

-- Calculate Total, Average, and Result


update student set Total = Sub1 + Sub2 + Sub3;
update student set Average = Total / 3.0;

Display the content of table


select * from student;
Create Table:
create table employee (EmpNo number(10),Name varchar2(25),BasicSalary number(6,2),DA
number(6,2),GrossSalary number(6,2),YearlySalary number(6,2),IncomeTax number(6,2));

-- Insert sample data (optional)


insert into employee (EmpNo, Name, BasicSalary)
values (1, 'John', 40000),
(2, 'Mary', 60000),
(3, 'Anna', 30000);

-- Calculate DA, Gross Salary, Yearly Salary, and Income Tax


update employee set DA = 0.45 * BasicSalary;
update employee set GrossSalary = BasicSalary + DA;
update employee set YearlySalary = GrossSalary * 12;
update employee set IncomeTax = YearlySalary * 0.15 WHERE YearlySalary > 500000;
update employee set IncomeTax = YearlySalary * 0.10 WHERE YearlySalary <= 500000

Step 1: Calculate the DA (Dearness Allowance) as 45% of the basic salary.


Step 2: Calculate the Gross Salary by adding the Basic Salary and DA.
Step 3: Calculate the Yearly Salary by multiplying the Gross Salary by 12 (months).
Step 4: Use two separate queries to calculate the Income Tax:
Apply a 15% tax rate if the Yearly Salary is above 500,000.
Apply a 10% tax rate if the Yearly Salary is 500,000 or below.
This approach is easier to understand and beginner-friendly.

-- Display the table with calculations


select EmpNo, Name, BasicSalary, DA, GrossSalary, YearlySalary, IncomeTax
from employee;
CLASSES AND OBJETCS Question

Inside Class template

Outside Class Template


K-MAP

You might also like