0% found this document useful (0 votes)
89 views

Ip-Dbms-Sql Assignment

The document provides instructions for students to complete assignments on SQL queries. It includes sample tables and questions to write SQL commands to retrieve data from the tables by joining, filtering, sorting, aggregating, and performing calculations on the columns. It also asks to predict the output for some queries and explain SQL functions and concepts.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
89 views

Ip-Dbms-Sql Assignment

The document provides instructions for students to complete assignments on SQL queries. It includes sample tables and questions to write SQL commands to retrieve data from the tables by joining, filtering, sorting, aggregating, and performing calculations on the columns. It also asks to predict the output for some queries and explain SQL functions and concepts.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

CLASS- XII

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

a) To display all information about projects whose starting month is March.


b) To list the Projsize and Highest, Lowest and Average cost of each project
c) To list ID, ProjName, Projsize and Cost of all projects in descending order of start
date.
d) To count the number of projects of the Cost less than 10,00,000.
e) To display the project size and total number of projects of each size.

3. Predict the output of the following queries:


i. select instr('[email protected]','.');
ii. select substr('[email protected]',7,4);
iii. select left('[email protected]',5);

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

100012 BD776 Bhopal 1000 90 15/09/2002

100015 BD676 Kanpur 1000 80 15/09/2002

100017 BD652 Agra 900 70 20/09/2002

100020 BD776 Manali 600 35 18/09/2002

100119 BD652 Madras 2000 75 22/09/2002

100032 BD776 Mumbai 1800 36 15/09/2002

a) To fetch last two characters of Destinatoon column.


b) To display the values of Destination column in upper case.
c) To displaytwo characters from 2nd place from the column TrainNo.
d) To display the TicketNo , Destination and Fare in descending order of fare.
e) Write the output of the following commands:
I. Select Min(Fare) from Train;
II. Select Sum(Fare) from Train where TrainNo=’BD776’.;
III. Select Max(Capacity) from Train where TicketNo<100020;
IV. Select Count(Distinct TrainNo) from Train;

6. Reena is working with functions of MySQL. Explain her following:


i. What is the purpose of now () function?
ii. How many parameters does it accept?
iii. What is the general format of its return type

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

a) Display the total number of employees in each department.


b) Display the highest salary, lowest salary, and average salary of each zone.
c) Display the average age of employees in each department only for those
departments in which average age is more than 30.
d) Based on the above given table :
Select count(*) from Employee;
Select count(Grade) from Employee;
Predict the output of the above given queries.
Also give proper justifications of the output generated through each query

9. Write SQL commands for (a) to (f) and write output of the (g) on the basis of the table teacher.
Table: TEACHER

S.No. Name Age Department Date Of Salary GENDER


1 Jugal 34 Computer 10/01/97 12000 M
2 Sharmila 31 History 24/03/98 20000 F
3 Sundeep 32 Maths 12/12/96 30000 M
4 Sangeeta 35 History 01/07/99 40000 F
5 Rakesh 42 Maths 05/09/97 25000 M
6 Shyam 50 History 27/06/98 30000 M
7 Shiv Om 44 Computer 25/02/97 21000 M
a. To count the number of teachers with age>23.
b. Write a query to count the number of employees in each department.
c. To find the highest salary in each department.
d. To calculate the average salary of male teachers.
e. Give the output of the following SQL commands:
i. select COUNT(distinct department) from teacher ;
ii. select MAX (Age) from teacher where GENDER=`F’;
iii. select SUM (Salary) from teacher where DATE OF ADM <{12/07/98};

10. Given the following relation answers the following:


TABLE: CARMARKET

CARCODE CARNAME COMPANY COLOR COST DOM


C01 BALENO SUZUKI BLUE 5.90 2019-11-07
C02 INDIGO TATA SILVER 12.90 2020-10-15
C03 GLC MERCEDES WHITE 62.38 2020-01-20
C04 A6 AUDI RED 58.55 2018-12-29
C05 INNOVA TOYOTA BLACK 32.82 2017-11-10
C06 WAGON-R SUZUKI WHITE 12.11 2016-11-11
C07 BREZZA SUZUKI GOLDEN 9.80 2016-10-03

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

You might also like