Class 11 Record
Class 11 Record
STUDENT DATABASE
Consider the following table Student. Write SQL commands for the statements (i) to (iv) and
give outputs for SQL queries (v) to (vii)
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
Write the SQL commands for the following using above tables:
i. To display the details of students who have got marks greater than 90.
select fname, marks from student where marks > 90;
ii. To display firstname,lastname and marks of the students whose marks are from 92 to
95.
select fname, lname, marks FROM student WHERE marks BETWEEN 92 and 95;
iii. To display the records in ascending order of marks and descending order of firstname
who have got marks greater than 90.
select fname, lname , marks from STUDENT WHERE marks >90 ORDER BY marks
ASC, fname DESC;
iv. To update date of birth and marks column to 2004-03-23 and 90 of a student
Deepakshi.
Update student set dob=’2004-03-23’,marks=90 where name=”Deepakshi”;
Give the output for the following SQL commands:
v. Select DISTINCT marks from student;
marks
98
92
95
94
93
84
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
Consider the following table Gym. Write SQL commands for the statements (i) to (iv) and give
outputs for SQL queries (v) to (vii)
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
Write the SQL commands for the following using above tables:
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 * from gym 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, DA integer, HRA integer, Bonus integer);
Result:
Thus the above SQL queries was executed successfully.
9. EMPLOYEE AND EMPSALARY DATABASE
Consider the following tables Employees and EmpSalary. Write SQL commands for the
statements (i) to (iv) and give outputs for SQL queries (v) to (vii)
Table: Employees
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
Employees 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));
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
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;
customername Manufacturer
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.