SQL Assignment
SQL Assignment
SUBMITTED BY:-
STUDENTS NAME
CLASS – XII
Page | 2
QUESTION – 1 – ALL OPERATIONS AT A GLANCE
Use the following table to answer the queries given below :
Table: empinfo
first last id age city state
John Jones 99980 45 Payson Arizona
Mary Jones 99982 25 Payson Arizona
Eric Edwards 88232 32 San Diego California
Mary Ann Edwards 88233 32 Phoenix Arizona
Ginger Howell 98002 42 Cottonwood Arizona
Sebastian Smith 92001 23 Gila Bend Arizona
Gus Gray 22322 35 Bagdad Arizona
Mary Ann May 32326 52 Tucson Arizona
Erica Williams 32327 60 Show Low Arizona
Leroy Brown 32380 22 Pinetop Arizona
Elroy Cleaver 32382 22 Globe Arizona
(a) Display everyone's first name and their age for everyone that's in table.
(b) Display the first name, last name, and city for everyone that's not from Payson.
SQL> select first, last, city from empinfo where city <> 'Payson';
(c) Display all columns for everyone that is over 40 years old.
(d) Display the first and last names for everyone whose last name ends in an "ay".
SQL> select first, last from empinfo where last LIKE '%ay';
(e) Display all columns for everyone whose first name equals "Mary".
(f) Display all columns for everyone whose first name contains "Mary".
Page | 3
Q.2. Create Table Exercise
You have just started a new company. It is time to hire some employees. You will need to
create a table that will contain the following information about your new employees:
firstname, lastname, title, age, and salary.
(firstname varchar(30),
lastname varchar(30),
title varchar(30),
age number(2),
salary number(8,2));
Enter these employees into your table first, and then insert at least 5 more of your own
list of employees in the table.
Q.4. After they're inserted into the table, enter select statements to:
(b) Select all columns for everyone with a salary over 30000.
(c) Select first and last names for everyone that's under 30 years old.
SQL> select firstname, lastname from myemployees where age < 30;
Page | 4
(d) Select first name, last name, and salary for anyone with "Programmer" in their title.
(e) Select all columns for everyone whose last name contains "ebe".
SQL> select * from myemployees where lastname LIKE '% ebe %';
(f) Select the first name for everyone whose first name equals "Potsy".
(h) Select all columns for everyone whose last name ends in "ith".
Jonie Weber-Williams just quit, remove her record from the table:
It's time for budget cuts. Remove all employees who are making over 70000 dollars.
items_ordered
customers
Page | 6
(a) Select the maximum price of any item ordered in the items_ordered table. Hint:
Select the maximum price only.
(b) Select the average price of all of the items ordered that were purchased in the
month of Dec.
(c) What are the total number of rows in the items_ordered table?
(d) For all of the tents that were ordered in the items_ordered table, what is the price
of the lowest tent? Hint: Your query should return the price only.
Page | 7
QUESTION – 2 – SENDER AND RECIPIENT
Consider the following tables. Write SQL commands for the statements (i) to (iv) and
give outputs for SQL queries (v) to (viii):
TABLE: SENDER
TABLE : RECIPIENT
Page | 8
(v) SELECT DISTINCT SenderCity FROM Sender;
SenderCity
New Delhi
Mumbai
SenderName RecName
R Jain H Singh
S Jha P K Swamy
RecName RecAddress
S Mahajan 116,A Vihar
S D Tripathi 13 B1, Mayur Vihar
RecID RecName
ND08 S Mahajan
ND48 S D Tripathi
Page | 9
QUESTION – 3 CONSIGNOR AND CONSIGNEE
Consider the following tables Consignor and Consignee. Write SQL commands for the
statements (i) to (iv) and give outputs for SQL queries (v) to (viii).
TABLE : CONSIGNOR
TABLE : CONSIGNEE
(ii) To display the CneelD, CnorName, CnorAddress, CneeName, CneeAddress for every
Consignee.
Page | 10
(v) SELECT DISTINCT City FROM CONSIGNEE;
CneeCity
Mumbai
New Delhi
Kolkata
CnorName CneeName
CneelD CneeName
KO19 A P Roy
Page | 11
QUESTION – 4 : GAMES AND PLAYER
Consider the following tables GAMES and PLAYER and answer (b) and (c) parts of this
question:
Table: GAMES
Table: PLAYER
(ii) To display details of those GAMES which are having PrizeMoney more than 7000.
(iii) To display the content of the GAMES table in ascending order of Schedule Date.
Page | 12
(c) Give the output of the following SQL queries: 2
Number
MAX(ScheduleDate) MIN(ScheduleDate)
19-Mar-2004 12-Dec-2003
Name GameName
GCode
101
103
108
Page | 13
QUESTION 5 : RESORT AND OWNER
Consider the following table RESORT and OWNER and answer questions (A)
and (B)
Table : RESORT
Table : OWNEDBY
PLACE OWNER
GOA SUN VILLAGE
KERALA KTDC
HIMANCHAL KALRA RESORTS
GUJARAT KINJAL GROUP
ORISSA OTDC
(A) Write SQL commands for the following statements:
(i) to display the RCODE and PLACE of all ‘2 Star’ resorts in the alphabetical
order of the place from table RESORT.
SQL> Select owner from RESORT R,OWNEDBY O where TYPE= ‘5 Star’ and
R.PLACE=O.PLACE;
Page | 14
(B) Give output for the following queries:
12000
(ii) SELECT TYPE, STARTDATE FROM RESORT WHERE TYPE=’2 Star’
ORDER BY STARTDATE;
TYPE STARTDATE
2 Star 29 Apr 2008
2 Star 25 Jan 2004
(iii) SELECT PLACE, OWNER FROM OWNEDBY WHERE PLACE LIKE ‘%L’;
PLACE OWNER
HIMANCHAL KALRA RESORTS
RCODE RENT
R101 15000
R103 12500
R106 16000
Page | 15
CERTIFICATE
This is to certify that the Practical Assignment in SQL has been successfully carried
out by , Student of CLASS XII, ST.
MONTFORT SR. SEC. SCHOOL, BHOPAL , for the partial fulfillment of the requirement of
"HIGHER SECONDARY EXAMINATION”.
Their performance has been good and we wish them good luck for their future.
EXTERNAL EXAMINER
Page | 16