Day2 Practice Sheet
Day2 Practice Sheet
Day2 Practice Sheet
DAY-2
1. Find the output of the following SQL queries :
(i) SELECT lower(SUBSTR(“FIT INDIA MOVEMENT”, -8))
(ii) SELECT INSTR(“ARTIFICIAL INTELLIGENCE”, “CI”)
2. Ms. Mohini is working in a school and stores the details of all students in a table SCHOOLDATA.
TABLE : SCHOOLDATA
Admno Name Class House Percent Gender Dob
20150001 Aditya Das 10 Green 86 Male 2006-02-20
20140212 Harsh Sharma 11 Red 75 Male 2004-10-05
20090234 Swapnil Pant 10 Yellow 84 Female 2005-11-21
20130216 Soumen Rao 9 Red 91 Male 2006-04-10
20190227 Rahil Arora 10 Blue 70 Male 2005-03-14
20120200 Akasha Singh 11 Red 64 Female 2004-12-16
Write SQL statements from the above given table to :
(i) To remove leading spaces from the column Name.
3. Predict the output of SQL queries from the table SCHOOLDATA given in above question
(i) SELECT LEFT(Gender,1), Name FROM SCHOOLDATA WHERE YEAR(Dob)=2005;
4. Predict the output of the following SQL queries : 3
(i) SELECT TRIM(" ALL THE BEST “);
(ii) SELECT UPPER(Mid(“Startup india”,10));
5. Consider a table "MYPET" with the following data and write SQL query for given statement-
Table : MYPET
Pet_id Pet_Name Breed LifeSpan Price Discount
101 Rocky Labrador Retriever 12 16000 5
202 Duke German Shepherd 13 22000 10
303 Oliver Bulldog 10 18000 7
404 Cooper Yorkshire Terrier 16 20000 12
505 Oscar Shih Tzu NULL 25000 8
(i) Display the Breed of all the pets in uppercase.
6. Write the names of SQL functions to perform the following operations : 3
(i) Convert email-id to lowercase.
(ii) Count the number of characters in your name.
7. Consider table : PRODUCT and predict output 3
Table : PRODUCT
PID PNAME PRICE QUANTITY
PIOOI Eraser 10.50 5
P1002 Ball Pen 15.00 2
P1003 Gel Pen 25.10 3
P1004 Ruler 5.00 1
(i) SELECT UCASE(RIGHT(PNAME,2)) FROM PRODUCT;
8. Consider table : 4
Table : SALESMAN
Scode Sname Area Qtysold Dateofjoin
sool Ravi North 120 2015-10-01
S002 Sandeep South 105 2012-08-01
S003 Sunil NULL 68 2018-02-01
s004 Subh West 280 2010-04-01
s005 Ankit East 90 2018-10-01
S006 Raman North NULL 2019-12-01
Predict the output for the following SQL queries :
(i) SELECT LENGTH (Sname) FROM SALESMAN WHER MONTH(Dateofjoin)=10;
(ii) SELECT Sname FROM SALESMAN WHERE RIGHT(Scode,1)=5;
9. Predict the output of the following queries:
i. select instr('exams@cbse.nic.in','.');
ii. select substr('exams@cbse.nic.in',7,4);
iii. select left('exams@cbse.nic.in',5);
10. Ms.Saumya is working on a MySQL table named ‘Hotel’ having following structure: