QUERY-1
Table :STORE
Item Scode Qty Rate Lastbuy
ItemNo
2005 Sharpener 23 60 8 31-JUN-
Classic
09
2003 Balls 22 50 25 01-FEB-
10
2002 Gel Pen 21 150 12 24-FEB-
10
2006 Gel Pen 21 250
20 11-MAR-
Classic
09
2001 Eraser Small 22 220 6 19-JAN-
09
2004 Eraser Big 22 110
8 02-DEC-
09
2009 Ball Pen 0.5 21 180
18 03-NOV-
09
Write SQL commands for the following statements.
1) To display details of all items in the STORE table in
ascending order of lastbuy .
COMMAND:
select * from store order by lastbuy asc ;
OUTPUT:
2) To display ItemNo and Item name of those items from
STORE table whose rate is more than 15
COMMAND
select Itemno , Item from store where rate>15 ;
OUTPUT:
3) To display the record of those items whose Scode is
22 or Qty is more than 110 from the table store.
COMMAND:
select * from store where scode =22 or qty>110;
OUTPUT:
4)To display minimum rate of items.
COMMAND:
select min(rate) from store
OUTPUT:
5)To display the item with its quantity which includes pen
in their name.
COMMAND:
Select item,qty From store where item like ‘%pen%’ ‘
OUTPUT:
QUERY-2
Table:FAMILY
NoName Female Male Income Occupation
. MembeMembe
rr
1 Mishra 3 2 7000 Service
2 Gupta 4 1 50000 Business
3 Khan 6 3 8000 Mixed
4 Chaddh2 2 25000 Business
a 20000 Mixed
5 Yadav 7 2 14000 Service
6 Joshi 3 2 5000 Farming
7 Maurya 6 3 10000 Service
8 Rao 5 2
Write SQL Command for the following questions.
1) To select all the information of family whose
occupation is Service.
COMMAND:
select *from family where occupation=’Service’;
OUTPUT:
2)To list the name of family where female members are
more than 3.
COMMAND:
select name from family where Femalemembers>3;
OUTPUT:
3)To list all names of family with income in ascending
order.
COMMAND:
select name from family order by incomes asc ;
OUTPUT:
4)To count the no. of family whose income is less than
10000.
COMMAND:
Select count(*) from family where income<10000:
OUTPUT:
5)To display the details of family whose income is more
than 10000 and occupation is mixed type.
COMMAND:
Select * from family where income<10000 and
occupation=’mixed’ ;
OUTPUT:
QUERY-3
Table :STUDENT
Roll No Name Gender Marks DOB
10-OCT-
1 Ajay M 79 06
12-OCT-
2 Bhoomi F 89 06
16-SEP-
3 Bhuvan M 70 06
20-FEB-
4 Farhan M 90 04
20-MAR-
5 Harsh M 50 06
Write SQL Command for the following questions.
1) Display the records of student whose roll no is 2,3 and
5
COMMAND:
Select *from student where roll no=2 and roll no=3
and roll no=5;
OUTPUT:
2)Display the records of student whose marks is more
than 80 and is Male.
COMMAND:
Select * from student where marks>80 and
gender=’Male’;
OUTPUT:
3)Display Name and Marks of students whose marks
are not between 80 to 100.
COMMAND:
Select name, marks from student where marks not
between 80 and 100 ;
OUTPUT:
4)Display the record of those students whose name
have 5 characters.
COMMAND:
Select * From student Where name like’_____’;
OUTPUT:
5)Display minimum marks from the table student.
COMMAND:
Select min(marks) From student;
OUTPUT:
QUERY-4
Table:EMPLOYEE
Sno Name Basic Department Age Sex
1 Karan 8000 Personnel 35 MM
2 Divyakar 9500 Computer 34 F
3 Divya 7300 Accounts 34 MF
4 Arun 8350 Personnel 37
5 Sabina 9500 Maintenance 37
Write SQL Command for the following questions.
1)Display the records of those employee’s age is more
than 35.
COMMAND:
Select *from employee where age>35;
OUTPUT:
2)Insert the following data in the employee table: 6 ‘Vijay’
9300 ‘Finance’ 32 ‘M’
COMMAND:
Insert into employee Values
(6.”Vijay”,9300,”Finance”,32,’M’) ;
OUTPUT:
3)Count the no. of employee who are working in
Personnel or Computer department.
COMMAND:
Select count(*) from employee where
department=’Computer’ or ‘Personnel’ ;
OUTPUT:
4)To display max basic from employee table.
COMMAND:
Select max(basic) from employee;
OUTPUT:
5)Display average age from the table employee.
COMMAND:
Select avg(age) from employee;
OUTPUT: