Ip-Dbms-Sql Assignment
Ip-Dbms-Sql Assignment
INFORMATICS PRACTICES
UNIT 2: DATABASE QUERY USING SQL
ASSIGNMENT
1. Give the output for the following SQL Statements.
a. SELECT SUBSTR(TRIM(‘ INDIA IS GREAT ’),4,2);
b. SELECT ROUND(76.9878,2);
c. SELECT LENGTH( ‘NETWROKING’);
d. SELECT INSTR(‘INTERNATIONAL’,’NA’);
e. SELECT MID(‘I M LOVING IT’ , -2 , 1);
f. SELECT POW(2,4);
g. SELECT LENGTH(‘C.B.S.E’);
h. SELECT RIGHT(‘USS/23/67/09’, 2);
i. SELECT MOD(7,3);
j. SELECT LEFT(‘RAMESH SHARMA’,5);
k. SELECT SUBSTR(‘PROGRAMMING’, -5,4);
l. SELECT POWER(5,3);
m. SELECT MOD(5,3);
n. SELECT ROUND(8.72,3);
o. SELECT ROUND(9.8);
2. Consider the table project given below. Write commands in SQL for (a) to (d) and output for (e).
Relation: PROJECT
ProjName Projsize Startdate Enddate Cost
ID
1 MMS Medium 2006-03-17 2006-09-16 60000
2 ITC Large 2008-01-11 2008-01-11 500000
3 LITL Large 2008-06-13 2009-05-21 300000
4 Re-litl Medium 2008-03-18 2008-06-01 50000
5 MTC Small 2007-01-15 2007-01-29 20000
6 Re-ITC medium 2007-03-01 2007-06-28 500000
4. While dealing with string data type in MySQL, its observed that sometimes unnecessary space
character comes in between which hampers the successful execution of a string manipulation
module. Name the suitable MySQL function (s) to remove leading, trailing and both type of space
characters from a string. Also give MySQL queries to depict the same.
5. Write SQL Query for the given (i) to (v) Statements and Output for (vi) of Relation TRAIN
Relation: TRAIN
TicketNo TrainNo Destination Fare Capacity Date
7. Write SQL query to find the total number of customers from each country in the table (customer ID,
customer Name, country) using group by.
8. Consider the tables given below and Write SQL commands for the following:
Table: Employee
No Name Salary Zone Age Grade Dept
1 Mukul 30000 West 28 A 10
2 Kritika 35000 Centre 30 A 10
3 Naveen 32000 West 40 null 20
4 Uday 38000 North 38 C 30
5 Nupur 32000 East 26 null 20
6 Moksh 37000 South 28 B 10
7 Shelly 36000 North 26 A 30
9. Write SQL commands for (a) to (f) and write output of the (g) on the basis of the table teacher.
Table: TEACHER
(a) Display the carname along with charges rounded off to 1 digit after decimal place.
(b) Display the carname, color and position of character ‘E’ in the color of all cars.
(c) Display the carname, name of the company in lower case of all cars whose year(of DOM) is 2020
(d) Display the number of cars manufactured each year.
(e) What is the cardinality and degree of the table CARMARKET?
11.