Class 11 Record
Class 11 Record
STUDENT DATABASE
Table: Student
Rno Fname Lname Gender dob marks
1 Abishek Narula M 1998-10-05 98
2 Bishek Pahuja M 1998-12-30 92
3 Bhushan Verma M 1998-02-27 95
4 Chetali Sapra F 1998-06-12 94
5 Chetanya Sharma M 1998-07-29 93
6 Dev Upadhyay F 1998-06-12 84
7 Daksh Arora M 1997-08-14 84
8 Deepakshi Shanu F NULL NULL
vi. select fname from student where gender ='f' and marks>90;
fname
Chetali
Result:
Thus the above SQL queries was executed successfully.
7. FITNESS PRODUCTS DATABASE
Table: Gym
Prcode Prname Price Manufacturer
P101 Cross Trainer 25000 Avon Fitness
P102 TreadMill 32000 AG Fitline
P103 Massage Chair 20000 Fit Express
P104 Vibration Trainer 22000 Avon Fitness
P105 Bike 13000 Fit Express
i. To Display the names and unit price of all the products in the store
select prname,price from gym;
iii. To Change the Unit Price data of all the rows by applying a 10% discount reduction
on all the products.
Update gym set price=price-price*0.1 ;
iv. To Display the names of all the products with unit price less than Rs.20000.00
select prname from gym where price < 20000;
Give the output for the following SQL commands:
v. Select * from gym where price between 20000 and 30000;
Prcode Prname Price Manufacturer
P101 Cross Trainer 25000 Avon Fitness
P103 Massage Chair 20000 Fit Express
P104 Vibration Trainer 22000 Avon Fitness
vi. select fname from student where Price >=25000 and manufacturer=’avon fitness’;
Prcode Prname Price Manufacturer
P101 Cross Trainer 25000 Avon Fitness
Result:
Thus the above SQL queries was executed successfully.
8. EMPLOYEE AND SALARY DATABASE
Consider the following tables Employee and Salary. Write SQL commands for the statements
(i) to (iv) and give outputs for SQL queries (v) to (vii)
Table: Employee
Eid Name Depid Qualification Gender
1 Deepali Gupta 101 MCA F
2 Rajat Tyagi 101 BCA M
3 Hari Mohan 102 B.A. M
4 Harry 102 M.A. M
5 Sumit Mittal 103 B.Tech. M
6 Jyoti 101 M.Tech. F
Table: Salary
create table salary(Eid integer, Basic integer, D.A integer, HRA integer, Bonus integer);
Result:
Thus the above SQL queries was executed successfully.
9. EMPLOYEE AND EMPSALARY DATABASE
Consider the following tables Employee and EmpSalary. Write SQL commands for the
statements (i) to (iv) and give outputs for SQL queries (v) to (vii)
Table: Employee
Table: Empsalary
Empid Salary Benefits Designation
010 75000 15000 Manager
102 65000 15000 Manager
152 80000 25000 Director
215 75000 12500 Manager
244 50000 12000 Clerk
300 45000 10000 Clerk
335 40000 10000 Clerk
400 32000 7500 Salesman
441 28000 7500 Salesman
create table employees(Empid integer ,Firstname varchar(30), lastname varchar(30),Address
varchar(30),City varchar(30));
insert into employees values(010,'Ravi','Kumar','Raj nagar','GZB');
insert into employees values(105,'Harry','Waltor','Gandhi Nagar','GZB');
insert into employees values(152,'Sam','Tones','33 Elm st','Paris');
insert into employees values(215,'Sarah','Ackerman','440 U.S 110','Upton');
insert into employees values(244,'Manila','Sengupta','24 Friends street','New Delhi');
insert into employees values(300,'Robert','Samuel','9 fifth cross','Washington');
insert into employees values(335,'Ritu','Tondon','Shastri nagar','GZB');
insert into employees values(400,'Rachel','Lee','121 Harrison st','New York');
insert into employees values(441,'Peter','Thomson','11 Red road','Paris');
create table empsalary(Empid integer,Salary integer,Benefits integer ,Designation char(30));
insert into empsalary values(010,75000,15000,'Manager');
insert into empsalary values(102,65000,15000,'Manager');
insert into empsalary values(152,80000,25000,'Director');
insert into empsalary values(215,75000,12500,'Manager');
insert into empsalary values(244,50000,12000,'Clerk');
insert into empsalary values(300,45000,10000,'Clerk');
insert into empsalary values(335,40000,10000,'Clerk');
insert into empsalary values(400,32000,7500,'Salesman');
insert into empsalary values(441,28000,7500,'Salesman');
Write the SQL commands for the following using above tables:
i. To display firstname, lastname, address and city of all employees living in Pairs.
select Firstname,Lastname,Address,City from employees where city='Paris';
iii. To display the firstname, lastname and total salary of all managers from the tables
Employes and EmpSalary, where total salary is calculated as salary + Benefits.
alter table empsalary ADD TotalSalary integer;
select salary,benefits,(salary+benefits) AS TotalSalary from empsalary;
select * from empsalary;
iv. To display the maximum salary among managers from the table Empsalary.
select max(salary) from empsalary where designation=’manager’;
Give the output for the following SQL commands:
v. Select firstname, Salary from Employees, Empsalary where Designation = ‘Salesman’ and
Employees.Empid = Empsalary.Empid;
Firstname Salary
Rachel 32000
Peter 28000
Designation
Clerk
Director
Manager
Salesman
Benefits
32000
Result:
Thus the above SQL queries was executed successfully.
10. GARMENT AND FABRIC DATABASE
Consider the following tables GARMENT and FABRIC. Write SQL commands for the
statements (i) to (iv) and give outputs for SQL queries (v) to (viii)
Table: GARMENT
GCODE Description price FCODE READYDATE
10023 PENCIL SKIRT 1150 F03 19-DEC-08
10001 FORAML SHIRT 1250 F01 12-JAN-08
10012 INFORMAL SHIRT 1550 F02 06-JUN-08
10024 BABY TOP 750 F03 07-APR-07
10090 TULIP SKIRT 850 F02 31-MAR-07
10019 EVENING GOWN 850 F03 06-JUN-08
10009 INFORMAL PANT 1500 F02 20-OCT-08
10007 FORMAL PANT 1350 F01 09-MAR-08
10020 FROCK 850 F04 09-SEP-07
10089 SLACKS 750 F03 31-OCT-08
Table: FABRIC
FCODE TYPE
F04 POLYSTER
F02 COTTON
F03 SILK
F01 NYLON
create table garment(GCODE integer,Description varchar(30),price integer,FCODE
varchar(30),READYDATE varchar(20));
insert into garment values(10023,'pencil skirt',1150,'F03','19-DEC-08');
insert into garment values(10001,'formal shirt',1250,'F01','12-JAN-08');
insert into garment values(10012,'informal shirt',1550,'F02','06-JUN-08');
insert into garment values(10024,'baby top',750,'F03','07-APR-07'); insert into
garment values(10090,'tulip skirt',850,'F02','31-MAR-07');
insert into garment values(10019,'evening gown',850,'F03','06-JUN-08');
insert into garment values(10009,'informal pant',1500,'F02','20-OCT 08');
insert into garment values(10007,'formal pant',1350,'F01','09-MAR-08');
insert into garment values(10020,'frock',850,'F04','09-SEP-07');
insert into garment values(10089,'slacks',750,'F03','31-OCT-08');
ii. To display the details of all the GARMENT, which have READYTYPE in between 08-DEC-07
and 16-JUN-08 (inclusive of both the dates)
select * from garment where readydate between '08-DEC-07' and '16-JUN-08';
iii. To display the average PRICE of all GARMENT, which are made up of FABRIC with FCODE as
FO3.
select avg(price) from garment where fcode ='f03';
iv. To display FABRIC wise highest and lowest price of GARMENT from GARMENT
table.(display FCODE of each GARMENT along with highest and lowest price)
select fcode, max(price),min(price) from garment group by fcode;
vi. select decription type from garment, fabric where garment.fcode = fabric.fcode and
garment.price>=1260 ;
Description TYPE
informal shirt COTTON
informal pant COTTON
formal pant NYLON
Result:
Thus the above SQL queries was executed successfully.
11. ITEM AND CUSTOMER DATABASE
Consider the following tables Item and Customer. Write SQL commands for the Statement (i)
to (iv) and give outputs for SQL queries (v) to (viii)
Table: ITEM
Itemid ItemName Manufacturer Price
PC01 Personal Computer Intel 35000
LC05 Laptop Intel 55000
PC03 Personal Computer HP 32000
PC06 Personal Computer Compaq 37000
LC03 Laptop Apple 57000
Table: CUSTOMER
Cusid CustomerName City Itemid
01 N Roy Delhi LC03
06 H Singh Mumbai PC03
12 R Pandey Delhi PC06
15 C Sharma Delhi LC03
16 K Agrawal Banglore PC01
create table item(Itemid varchar(10),Itemname char(50),Manufacturer char(10),Price integer);
insert into item values('PC01','Personal computer','intel',35000);
insert into item values('LC05','Laptop','intel',55000);
insert into item values('PC03','Personal computer','hp',32000);
insert into item values('PC06','Personal computer','compaq',37000);
insert into item values('LC03','Laptop','Apple',57000);
Write the SQL commands for the following using above tables:
iii. To display the CustomerName, City from table Customer, and ItemName and Price from
table Item, with their corresponding matching Itemid
select customername,city,itemname,price from item,customer where
item.itemid=customer.itemid;
iv. To increase the Price of all Items by 1000 in the table item
update item set price=price+1000;
Itemname ItemName
N Roy Apple
H Singh Hp
R Pandey compaq
C Sharma Apple
k Agrawal intel
Result:
Thus the above SQL queries was executed successfully.
12. IF ELSE IF STATEMENT
AIM:
To create if else something program using java
ALGORITHM:
1. Start the program
2. Get the input from the user
3. Check the inputs based on conditions
4. If the conditions is true, block will execute
5. If the condition is false, else if block will execute
6. Stop the program
PROGRAM:
import java.util.Scanner;
public class ifelse
{
public static void main(String[] args)
{
int number;
Scanner sc=new Scanner(System.in);
System.out.println("Enter the number");
number=sc.nextInt();
if(number>0)
System.out.println("The number is positive.");
else if(number<0)
System.out.println("The number is Negative.");
else
System.out.println("The number is 0");
}
}
OUTPUT:
Enter the number
9
The number is positive.
Enter the number
-7
The number is Negative.
Enter the number
0
The number is 0
RESULT:
Thus the above Java Program was Executed Successfully.
13. SWITCH CASE STATEMENT
AIM:
To create a switch case while statement program using java
ALGORITHM:
1. Start the program
2. Get the input with the case value
3. Match the input with case value
4. If match case, execute that case output statement
5. If no match case, default statement will be executed
6. Stop the program
PROGRAM:
import java.util.Scanner;
public class switchcase
{
public static void main(String[] args)
{
int daynum;
Scanner sc=new Scanner(System.in);
System.out.println("Enter a day number (1-7):");
daynum=sc.nextInt();
switch(daynum)
{
case 1:
System.out.println("Monday");
break;
case 2:
System.out.println("Tuesday");
break;
case 3:
System.out.println("Wednesday");
break;
case 4:
System.out.println("Thursday");
break;
case 5:
System.out.println("Friday");
break;
case 6:
System.out.println("Saturday");
break;
case 7:
System.out.println("Sunday");
break;
default:
System.out.println("Invalid day number.");
break;
}
}
}
OUTPUT:
Enter a day number (1-7):
3
Wednesday
Enter a day number (1-7):
6
Saturday
Enter a day number (1-7):
9
Invalid day number.
RESULT:
Thus the above Java Program was Executed Successfully.
14. WHILE STATEMENT
AIM:
To create a while statement program using java
ALGORITHM:
1. Start the program
2. Get the input from the user
3. Check the initial value and the condition
4. If the condition is true, execute the loop till it becomes false
5. Stop the program
PROGRAM:
import java.util.Scanner;
public class whileexample
{
public static void main(String[] args)
{
int i;
System.out.println("Enter the value:");
Scanner sc=new Scanner(System.in);
i=sc.nextInt();
while(i<=10)
{
System.out.println(i);
i++;
}
}
}
OUTPUT:
Enter the value: 5
5
6
7
8
9
10
RESULT:
Thus the above Java Program was Executed Successfully.
15. Do while statement
AIM:
To create a do while statement program using java
ALGORITHM:
1. Start the program
2. Get the input from the user
3. Execute the loop
4. Check the increment or document operation and check the condition statement
5. Stop the program
PROGRAM:
import java.util.Scanner;
public class dowhileexample
{
public static void main(String[] args)
{
int i;
System.out.println("Enter the value:");
Scanner sc=new Scanner(System.in);
i=sc.nextInt();
do
{
System.out.println(i);
i++;
}
while(i<=10);
}
OUTPUT:
Enter the value: 7
7
8
9
10
RESULT:
Thus the above Java Program was Executed Successfully.