0% found this document useful (0 votes)
149 views25 pages

Class Xii Lab Manual (21 To 22) Full Book

The document contains examples of SQL queries and commands used to retrieve information from and manipulate data within multiple database tables. The tables contain employee, salary, garment, fabric, item, customer, sender, and recipient data. SQL commands are provided to select, insert, update, group, count, sum, max and min data values. Output is given for queries finding max salaries, counts by groups, sums, and selecting related data between tables. The document demonstrates basic and advanced SQL operations on a variety of sample databases.
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)
149 views25 pages

Class Xii Lab Manual (21 To 22) Full Book

The document contains examples of SQL queries and commands used to retrieve information from and manipulate data within multiple database tables. The tables contain employee, salary, garment, fabric, item, customer, sender, and recipient data. SQL commands are provided to select, insert, update, group, count, sum, max and min data values. Output is given for queries finding max salaries, counts by groups, sums, and selecting related data between tables. The document demonstrates basic and advanced SQL operations on a variety of sample databases.
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/ 25

INFORMATION TECHNOLOGY (802) CLASS XII

1. 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
Eid Basic D.A HRA Bonus
1 6000 2000 2300 200
2 2000 300 300 30
3 1000 300 300 40
4 1500 390 490 30
5 8000 900 900 80
6 10000 300 490 89

Write the SQL commands for the following using above tables:
(i) To display the details of all the employees.
(ii) To list the names of those employees only whose name starts with ‘H’
(iii) To add a new column in salary table. The column name is Total_Sal.
(iv) To store the corresponding values in the Total_Sal column.
Give the output for the following SQL commands:
(v) Select max (Basic) from salary where Bonus > 40;
(vi) Select count (*) from Employee group by Gender;
(vii) Select Distinct Depid from Employee;

MR.G.ANBARASU PRACTICAL LAB MANUAL


PAAVAI VIDHYASHRAM, NAMAKKAL 12
INFORMATION TECHNOLOGY (802) CLASS XII

3. 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

Write the SQL commands for the following using above tables:
(i) To display GCODE and DESCRIPTION of each GARMENT in descending order of GCODE.
(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)
(iii) To display the average PRICE of all GARMENT, which are made up of FABRIC with FCODE as FO3.
(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)

Give the output for the following SQL commands:

(v) SELECT SUM (PRICE)FROM GARMENT WHERE FCODE = ‘F01’ ;


(vi) SELECT DECRIPTION TYPE FROM GARMENT, FABRIC WHERE GARMENT.FCODE = FABRIC.FCODE AND
GARMENT.PRICE>=1260 ;
(vii) SELECT MAX (FCODE) FROM FABRIC;
(viii) SELECT COUNT (DISTINCT PRICE) FROM GARMENT;

MR.G.ANBARASU PRACTICAL LAB MANUAL


PAAVAI VIDHYASHRAM, NAMAKKAL 14
INFORMATION TECHNOLOGY (802) CLASS XII

4. 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

Write the SQL commands for the following using above tables:
(i) To display the details of those Customers whose City is Delhi
(ii) To display the details of Item whose Price is in the range of 35000 to 55000
(Both values included)
(iii) To display the CustomerName, City from table Customer, and ItemName and Price
from table Item, with their corresponding matching Itemid
(iv) To increase the Price of all Items by 1000 in the table item
Give the output for the following SQL commands:
(v) SELECT DISTINCT City FROM Customer ;
(vi) SELECT ItemName, Max(Price), Count(*) FROM Item GROUP BY ItemName;
(vii) SELECT CustomerName, Manufacturer FROM Item, Customer
WHERE Item.Itemid = Customer.Itemid ;
(viii) SELECT ItemNmae, Price * 10 FROM Item Where Manufacturer = ‘Intel’;

MR.G.ANBARASU PRACTICAL LAB MANUAL


PAAVAI VIDHYASHRAM, NAMAKKAL 15
INFORMATION TECHNOLOGY (802) CLASS XII

5. SENDER AND RECIPIENT DATABASE


Consider the following tables. Write SQL commands for the statements (i) to (iv) and give outputs for SQL
queries (v) to (viii)
TABLE : SENDER

SID SName SAddress SCity

ND01 R Jain 2, ABC Appts New Delhi

MU02 H Saina 12, Newtown Mumbai

MU15 S Jha 27/A, Park Street Mumbai

ND50 T Prasad 122-K, SDA New Delhi

TABLE : RECIPIENT

RID SID RName RAddress RCity

KO05 ND01 R Bajpayee 5, Central Avenue Kolkata

ND08 MU02 S Mahajan 116, A Vihar New Delhi

MU19 ND01 H Singh 2A, Andheri East Mumbai

MU32 MU15 P K Swamy B5, C S Terminus Mumbai

ND48 ND50 S Tripathi 13, B1 D, Mayur Vihar New Delhi

Write the SQL commands for the following using above tables:
(i) To display the names of all Senders from Mumbai
(ii) To display the RID, SName, SAddress, RName, RAddress for every Recipient
(iii) To display Recipient details in ascending order of Rec name
(iv) To display number of recipients from each city
Give the output for the following SQL commands:
(v) SELECT DISTINCT SCity from sender;
(vi) SELECT A. SName, B.RName FROM Sender A, Recipient B
WHERE A. SID = B.SID AND B.RCity = ‘Mumbai’;
(vii) SELECT Rec Name, Rec Address FROM Recipient
WHERE Rec City NOT IN (‘Mumbai’, ‘Kolkata’);
(viii) SELECT Rec ID , Rec Name FROM Recipient
WHERE Sender ID = ‘MU02’ OR Sender ID = ‘ND50’;
MR.G.ANBARASU PRACTICAL LAB MANUAL
PAAVAI VIDHYASHRAM, NAMAKKAL 16
INFORMATION TECHNOLOGY (802) CLASS XII

JAVA PROGRAMS
6.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
FLOWCHART:

MR.G.ANBARASU PRACTICAL LAB MANUAL


PAAVAI VIDHYASHRAM, NAMAKKAL 17
INFORMATION TECHNOLOGY (802) CLASS XII

PROGRAM:
import java.util.Scanner;
public class IfElse
{
public static void main(String[] args)
{
int marks;
Scanner sc=new Scanner(System.in);
System.out.println("Enter the Mark");
mark=sc.nextint();
if(marks<50)
{
System.out.println("fail");
}
else if(marks>=50 && marks<60)
{
System.out.println("D grade");
}
else if(marks>=60 && marks<70)
{
System.out.println("C grade");
}
else if(marks>=70 && marks<80)
{

MR.G.ANBARASU PRACTICAL LAB MANUAL


PAAVAI VIDHYASHRAM, NAMAKKAL 18
INFORMATION TECHNOLOGY (802) CLASS XII

System.out.println("B grade");
}
else if(marks>=80 && marks<90)
{
System.out.println("A grade");
}
else if(marks>=90 && marks<100)
{
System.out.println("A+ grade");
}
else
{
System.out.println("Invalid!");
}
}
}

OUTPUT:
Enter the mark 90
A+ grade
Enter the mark 55
D grade
Enter the mark 65
C grade

RESULT:
Thus the above Java Program was Executed Successfully.

MR.G.ANBARASU PRACTICAL LAB MANUAL


PAAVAI VIDHYASHRAM, NAMAKKAL 19
INFORMATION TECHNOLOGY (802) CLASS XII

7. 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
FLOWCHART

MR.G.ANBARASU PRACTICAL LAB MANUAL


PAAVAI VIDHYASHRAM, NAMAKKAL 20
INFORMATION TECHNOLOGY (802) CLASS XII

PROGRAM:
import java.util.Scanner;
public class switchcase
{
public static void main(String[] args)
{
char ch;
Scanner sc=new Scanner(System.in);
System.out.println("Enter the Alphabet Letter ");
ch= sc.next().charAt(0);
switch(ch)
{
case 'a':
System.out.println("Vowel");
break;
case 'e':
System.out.println("Vowel");
break;
case 'i':
System.out.println("Vowel");
break;
case 'o':
System.out.println("Vowel");
break;
case 'u':

MR.G.ANBARASU PRACTICAL LAB MANUAL


PAAVAI VIDHYASHRAM, NAMAKKAL 21
INFORMATION TECHNOLOGY (802) CLASS XII

System.out.println("Vowel");
break;
case 'A':
System.out.println("Vowel");
break;
case 'E':
System.out.println("Vowel");
break;
case 'I':
System.out.println("Vowel");
break;
case 'O':
System.out.println("Vowel");
break;
case 'U':
System.out.println("Vowel");
break;
default:
System.out.println("Consonant");
}
}
}

MR.G.ANBARASU PRACTICAL LAB MANUAL


PAAVAI VIDHYASHRAM, NAMAKKAL 22
INFORMATION TECHNOLOGY (802) CLASS XII

OUTPUT:
Enter the alphabet
a
It is a vowel
Enter the alphabet letter
E
Enter the alphabet letter
e
It is a vowel
Enter the alphabet letter
D
It is a consonant

RESULT:
Thus the above Java Program was Executed Successfully.

MR.G.ANBARASU PRACTICAL LAB MANUAL


PAAVAI VIDHYASHRAM, NAMAKKAL 23
INFORMATION TECHNOLOGY (802) CLASS XII

13. SWAPPING OF TWO NUMBERS USING USER DEFINED METHOD


AIM
To create a java program for swapping of two numbers using user defined method
ALGORITHM
1. Start the program
2. Get the import for first and second number from the user
3. Create a user defined method for swapping by passing arguments in the method call
4. When a method is called, control is transferred from the calling method to the called
method
5. Swapping occurs with the help of third variable
6. Print the output after swapping
7. Stop the program

PROGRAM:
import java.util.Scanner;
public class swaping
{
private static Scanner sc;
public static void main(String[] args)
{
int a, b;
sc = new Scanner(System.in);
System.out.print(" Please Enter the First value : ");
a = sc.nextInt();
System.out.print(" Please Enter the Second value : ");
b = sc.nextInt();
System.out.println("\n Before Swapping: a = " + a + " and b = " + b);

MR.G.ANBARASU PRACTICAL LAB MANUAL


PAAVAI VIDHYASHRAM, NAMAKKAL 37
INFORMATION TECHNOLOGY (802) CLASS XII

swapping(a, b);
}
public static void swapping(int a, int b)
{
int temp;
temp = a;
a = b;
b = temp;
System.out.println("\n After Swapping: a = " + a + " and b = " + b);
}
}

OUTPUT:
Please Enter the First value: 5
Please Enter the Second value: 6

Before Swapping: a = 5 and b = 6


After Swapping: a = 6 and b = 5

RESULT:
Thus the above Java Program was Executed Successfully.

MR.G.ANBARASU PRACTICAL LAB MANUAL


PAAVAI VIDHYASHRAM, NAMAKKAL 38
INFORMATION TECHNOLOGY (802) CLASS XII

14. STRING MANIPULATION OPERATION USING JAVA

AIM
To create a java program by using different string manipulation operation

ALGORITHM
1. Start the program
2. Assign a static input for the string variable
3. Display the character at position 6, using char chart (int index)
4. Concatenate the specified string at the end of giving string using stringconcat
(string str)
5. Returns “true” if the given string contains the specified sub string using Boolean
contains (string s) , else return “false”
6. Compare the given string with the specified string ignoring case if equal returns “true”
else return “false”
7. Stop the program

PROGRAM:
public class stringmanipulation
{
public static void main(String[] args)
{
String a="HELLO WORLD";
System.out.println("GIVEN STRING="+a);
System.out.println("chatAt position 6:"+a.charAt(6));
System.out.println("concat 'TODAY'="+a.concat(" TODAY"));
System.out.println("contains 'HELL'="+a.contains("HELL"));
System.out.println("endsWith 'old'="+a.endsWith("old"));

MR.G.ANBARASU PRACTICAL LAB MANUAL


PAAVAI VIDHYASHRAM, NAMAKKAL 39
INFORMATION TECHNOLOGY (802) CLASS XII

System.out.println("equals 'goodbye world'="+a.equals("goodbye world"));


System.out.println("equalsIgnorecase 'hello world'!="+a.equalsIgnoreCase("hello world"));
System.out.println("indexOf W="+a.indexOf('W'));
System.out.println("indexOf 'RLD'="+a.indexOf("RLD"));
System.out.println("isEmpty="+a.isEmpty());
System.out.println("length="+a.length());
System.out.println("replace L with *="+a.replace('L','*'));
System.out.println("replace 'HELLO' with 'YELLOW'="+a.replace("HELLO","YELLOW"));
System.out.println("LowerCase:"+a.toLowerCase());
System.out.println("UpperCase:"+a.toUpperCase());
}
}

OUTPUT:
GIVEN STRING =HELLO WORLD
chatAt position 6 =W
concat 'TODAY' =HELLO WORLD TODAY
contains 'HELL' =true
endsWith 'old' =false
equals 'goodbye world' =false
equalsIgnorecase 'hello world'! =true
indexOf W =6
indexOf 'RLD' =8
isEmpty =false

MR.G.ANBARASU PRACTICAL LAB MANUAL


PAAVAI VIDHYASHRAM, NAMAKKAL 40
INFORMATION TECHNOLOGY (802) CLASS XII

length =11
replace L with * =HE**O WOR*D
replace 'HELLO' with 'YELLOW' =YELLOW WORLD
LowerCase =hello world
UpperCase =HELLO WORLD

RESULT:
Thus the above Java Program was Executed Successfully.

MR.G.ANBARASU PRACTICAL LAB MANUAL


PAAVAI VIDHYASHRAM, NAMAKKAL 41
INFORMATION TECHNOLOGY (802) CLASS XII

DATABASE MANAGEMENT SYSTEM

ANSWER KEY

1.create table employee(Eid integer, Name varchar(30),Depid integer, Qualification


varchar(30), Gender char);

insert into employee values(1,'Deepali Gupta',101,'MCA','F');


insert into employee values(2,'Rajat Ryagi',101,'BCA','M');
insert into employee values(3,'Hari Mohan',102,'B.A','M');
insert into employee values(4,'Harry',102,'MA','M');
insert into employee values(5,'Sumit Mittal',103,'B.TECH','M');
insert into employee values(6,'Jyoti',101,'M.TECH','F');

create table salary(Eid integer, Basic integer, D.A integer, HRA integer, Bonus integer);

insert into salary values(1,6000,2000,2300,200);


insert into salary values(2,2000,300,300,30);
insert into salary values(3,1000,300,300,40);
insert into salary values(4,1500,390,490,30);
insert into salary values(5,8000,900,900,80);
insert into salary values(6,10000,300,490,89);

i. select * from 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

ii.select name from employee where name like "H%";


Name
Hari Mohan
Harry

MR.G.ANBARASU PRACTICAL LAB MANUAL


PAAVAI VIDHYASHRAM, NAMAKKAL 58
INFORMATION TECHNOLOGY (802) CLASS XII

iii.alter table salary add total_sal integer;


Eid int(11) YES NULL
Basic int(11) YES NULL
DA int(11) YES NULL
HRA int(11) YES NULL
Bonus int(11) YES NULL
total_sal int(11) YES NULL

iv.select basic,DA,HRA,Bonus,(Basic+DA+HRA+Bonus) AS Totsal from salary;


Basic D.A HRA Bonus Totsal
6000 2000 2300 200 10500
2000 300 300 30 2630
1000 300 300 40 1640
1500 390 490 30 2410
8000 900 900 80 9880
10000 300 490 89 10879

v. select max(basic) from salary where Bonus>40;


Max(Basic)
10000

vi. select count(*) from employee group by Gender;


Count(*)
4
2

vii. select distinct Depid from employee;


Depid
101
102
103

Result:
Thus the above SQL queries was executed successfully.

MR.G.ANBARASU PRACTICAL LAB MANUAL


PAAVAI VIDHYASHRAM, NAMAKKAL 59
INFORMATION TECHNOLOGY (802) CLASS XII

vii.select designation,sum(salary) from empsalary group by designation having count(*)>2;


Designation Salary
Clerk 135000
Manager 215000

viii. select sum(benefits)from empsalary where designation='Clerk';


Benefits
32000

Result:
Thus the above SQL queries was executed successfully.

3. 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');

MR.G.ANBARASU PRACTICAL LAB MANUAL


PAAVAI VIDHYASHRAM, NAMAKKAL 62
INFORMATION TECHNOLOGY (802) CLASS XII

create table fabric(FOCDE varchar(10),TYPE varchar(30));

insert into fabric values('F04','POLYSTER');


insert into fabric values('F02','COTTON');
insert into fabric values('F00','SILK');
insert into fabric values('F01','NYLON');

i.select Gcode,Description from garment order by gcode desc;


GCODE Description
10090 tulip skirt
10089 slacks
10024 baby top
10023 pencil skirt
10020 frock
10019 evening gown
10012 informal shirt

10009 informal pant


10007 formal pant
10001 formal shirt

ii. select * from garment where readydate between '08-DEC-07' and '16-JUN-08';
GCODE Description price FCODE READYDATE
10001 formal shirt 1250 F01 12-JAN-08
10007 formal pant 1350 F01 09-MAR-08
10012 Informal shirt 1550 F02 06-JUN-08
10019 Evening gown 850 F03 06-JUN-08
iii. select avg(price) from garment where fcode ='f03';
AVG(PRICE)
875.00

iv. select fcode, max(price),min(price) from garment group by fcode;

FCODE MAX(PRICE) MIN(PRICE)


F01 1350 1250
F02 1550 850
F03 1150 750
F04 850 850

v.select sum(price) from garment where fcode='F01';


SUM(PRICE)
2600

MR.G.ANBARASU PRACTICAL LAB MANUAL


PAAVAI VIDHYASHRAM, NAMAKKAL 63
INFORMATION TECHNOLOGY (802) CLASS XII

vi. select Description,TYPE from garment,fabric where garment.fcode=fabric.fcode and


garment.price>=1260;
Description TYPE
informal shirt COTTON
informal pant COTTON
formal pant NYLON

vii.select max(fcode) from fabric;


FCODE
F04

viii. select count(distinct price) from garment;


COUNT(PRICE)
7

Result:
Thus the above SQL queries was executed successfully.

4. 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);

create table customer(Cusid integer,Customername char(50),City char(10),Itemid varchar(10));

insert into customer values(01,'N Roy','Delhi','LC03');


insert into customer values(06,'H Singh','Mumbai','PC03');
insert into customer values(12,'R Pandey','Delhi','PC06');
insert into customer values(15,'C Sharma','Delhi','LC03');
insert into customer values(16,'k Agrawal','Banglore','PC01');

MR.G.ANBARASU PRACTICAL LAB MANUAL


PAAVAI VIDHYASHRAM, NAMAKKAL 64
INFORMATION TECHNOLOGY (802) CLASS XII

i. select * from customer where city='Delhi';


Cusid CustomerName City Itemid
1 N Roy Delhi LC03
12 R Pandey Delhi PC06
15 C Sharma Delhi LC03

ii.select * from item where price between 35000 and 55000;


Itemid ItemName Manufacturer Price
PC01 Personal computer Intel 35000
LC05 Laptop Intel 55000
PC06 Personal computer Compaq 37000

iii. select customername,city,itemname,price from item,customer where


item.itemid=customer.itemid;
CustomerName City Itemname price
N Roy Delhi Laptop 57000
H Singh Mumbai Personal computer 32000
R Pandey Delhi Personal computer 37000
C Sharma Delhi Laptop 57000
k Agrawal Banglore Personal computer 35000

iv. update item set price=price+1000;


select * from item;
Itemid ItemName Manufacturer Price
PC01 Personal computer intel 36000
LC05 Laptop intel 56000
PC03 Personal computer hp 33000
PC06 Personal computer compaq 38000
LC03 Laptop apple 58000

v.select distinct city from customer;


City
Delhi
Mumbai
Banglore

MR.G.ANBARASU PRACTICAL LAB MANUAL


PAAVAI VIDHYASHRAM, NAMAKKAL 65
INFORMATION TECHNOLOGY (802) CLASS XII

vi. select itemname,max(price),count(*) from item group by itemname;

Itemname ItemName Count(*)


Laptop 57000 2
Personal computer 37000 3

vii. select customername,manufacturer from item,customer where tem.itemid=customer.itemid;


Itemname ItemName
N Roy Apple
H Singh Hp
R Pandey compaq
C Sharma Apple
k Agrawal intel

viii. select itemname,price *10 from item where manufacturer='intel';


Itemname ItemName
Personal computer 350000
Laptop 550000

Result:
Thus the above SQL queries was executed successfully.

5. create table sender(SID varchar(10),SName char(30),SAddress varchar(30),SCity char(20));

insert into sender values('ND01','R jain','2,ABC Appts','New Delhi');


insert into sender values('MU02','H Saina','12,Newtown','Mumbai');
insert into sender values('MU15','S Jha','27/A, Park street','Mumbai');
insert into sender values('ND550','T Prasad','122-K,SDA','New Delhi');

MR.G.ANBARASU PRACTICAL LAB MANUAL


PAAVAI VIDHYASHRAM, NAMAKKAL 66
INFORMATION TECHNOLOGY (802) CLASS XII

create table recipient(RID varchar(10),SID varchar(10),RName char(20),RAddress


varchar(50),RCity char(20));

insert into recipient values('K005','ND01','R Bajpayee','5,Central Avenue','kolkata');


insert into recipient values('ND08','MU02','S Mahajan','116,A vihar','New Delhi');
insert into recipient values('MU19','ND01','H Singh','2A, Andheri East','Mumbai');
insert into recipient values('MU32','MU15','P K Swamy','B5 CS Terminus','Mumbai');
insert into recipient values('ND48','ND50','S Tripathi','13, B1 D Mayur vihar','Mumbai');

i. select sname from sender where SCity='Mumbai';


SCity
H Saina
S Jha

ii. select RId,SName,SAddress,RName,RAddress from sender,recipient where


sender.sid=recipient.sid;

RID SName SAddress RName RAddress


K005 R jain 2,ABC Appts R Bajpayee 5,Central Avenue
ND08 H Saina 12,Newtown S Mahajan 116,A vihar
MU19 R jain 2,ABC Appts H Singh 2A, Andheri East
MU32 S Jha 27/A, Park street P K Swamy B5 CS Terminus

iii. select * from recipient order by RName ASC;


RID SID RName RAddress RCity
MU19 ND01 H Singh 2A, Andheri East Mumbai
MU32 MU15 P K Swamy B5 CS Terminus Mumbai
K005 ND01 R Bajpayee 5,Central Avenue kolkata
ND08 MU02 S Mahajan 116,A vihar New Delhi
ND48 ND50 S Tripathi 13, B1 D Mayur vihar Mumbai

iv. select RCity,count(*) from recipient group by RCity;


RCity Count
Kolkata 1
Mumbai 2
New Delhi 2

MR.G.ANBARASU PRACTICAL LAB MANUAL


PAAVAI VIDHYASHRAM, NAMAKKAL 67
INFORMATION TECHNOLOGY (802) CLASS XII

v. select distinct SCity from sender;


SCity
New Delhi
Mumbai

vi. select a.SName,b.RName from sender a, recipient b where a.SID=b.SID and


b.RCity='Mumbai';
SName RName
R jain H Singh
S Jha P K Swamy

vii. select RName,RAddress from recipient where RCity NOT IN ('Mumbai','Kolkata');


RName RAddress
S Mahajan 116,A vihar
S Tripathi 13, B1 D Mayur vihar

viii. select RId,RName from recipient where SID='MU02' OR SID='ND50';


RID RName
ND08 S Mahajan
ND48 S Tripathi

Result:
Thus the above SQL queries was executed successfully.

MR.G.ANBARASU PRACTICAL LAB MANUAL


PAAVAI VIDHYASHRAM, NAMAKKAL 68

You might also like