0% found this document useful (0 votes)
61 views9 pages

Holidays HW IP XII Page 3

The document contains questions about SQL commands and functions. It includes questions about updating records, aggregating data, joining tables, and performing calculations on data. Example queries are provided for many questions.

Uploaded by

Pooja Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
61 views9 pages

Holidays HW IP XII Page 3

The document contains questions about SQL commands and functions. It includes questions about updating records, aggregating data, joining tables, and performing calculations on data. Example queries are provided for many questions.

Uploaded by

Pooja Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

SUBJECT: INFORMATICS PRACTICES

CLASS: XII

WORKSHEET

1. What is the purpose of DROP TABLE command in SOL? How is it different from DELETE command?

2. In a database there are two tables "Product" as shown below :

Write the command To increase the Price of all the Products by 20.

3. Write the UPDATE command to change “Sharma” to “Singh” in the “LastName” column in the Employee
table.

4. What is the use of UPDATE statement in SQL ? How is it different from ALTER statement?

5. Consider the following table named "GYM"

Write command To change the Brandname to "Fit Trend India" of the item, whose ICODE as "G101 ".

6. Write the UPDATE statement in MySQL to increase commission by 100.00 in the ‘‘Commission’’ column
in the ‘Emp’ table.

7. Write two examples of DML commands of SQL.

8. In a database there are two tables ‘CD’ and ‘TYPE’ as shown below :
Write SQL statement to change the name of Singer ‘‘Sonvi Kumar’’ to ‘‘Sonvi Mehra’’ in all the places
wherever it occurs in CD table.

9. Consider the following table named “GARMENT”.

1) Write command To change the colour of garment with code as 116 to “Orange”.
2) Write command to increase the price of all XL garments by 10%
3) Write command to delete the record with GCode “116”

10. In a Database, there are two tables given below :

Write SQL command to change the JOBID to 104 of the Employee with ID as E4 in the table ‘EMPLOYEE’.

11. In Marks column of ‘Student’ table, for Rollnumber 2, the Class Teacher entered the marks as 45.
However there was a totaling error and the student has got her marks increased by 5. Which MySQL
command should she use to change the marks in ‘Student’ table.
12. Chhavi has created a table named Orders, she has been asked to increase the value of a column named
salesamount by 20. She has written the following query for the same.
Alter table Orders Add salesamount =salesamount+20;
Is it the correct query?Justify.

13. Consider the following table:


Table: PharmaDB

Write commands in SQL to increase the price of “Amlodipine” by 50.

14. Write the output of the following SQL queries:


a) SELECT ROUND(6.5675, 2);
b) SELECT TRUNCATE(5.3456, 1);
c) SELECT DAYOFMONTH('2009-08-25');
d) SELECT MID('Class 12', 2,3);
15. Write the output of the following SQL queries :
(i) SELECT INSTR(‘UNICODE’,’CO’);
(ii) SELECT RIGHT(‘Informatics’,3);

16. State difference between date functions NOW( ) and SYSDATE( ) of MySql.

17. Name a function of MySql which is used to remove trailing and leading spaces from a string.

18. Consider the following table named 'SBOP" with details


of account holders. Write output

(i) SELECT ROUND(Balance,-3) FROM SBOP WHERE


AccountNo=”SB-5”;

19. Write the output of the following SQL queries :


(i) SELECT RIGHT(‘software’, 2);
(ii) SELECT INSTR(‘twelve’,‘lv’);
(iii) SELECT DAYOFMONTH(‘2014-03-01’);
(iv) SELECT ROUND(76.987, 2);
20. Write the output of the following SQL queries:
i. SELECT INSTR(‘INTERNATIONAL’, ‘NA’);
ii. SELECT LENGTH(CONCAT(‘NETWORK’,’ING’));
iii.SELECT ROUND(563.345,-2);
iv. SELECT DAYOFYEAR(‘2014-01-30’);
21. Pranay, who is an Indian, created a table named “Friends” to store his friend’s detail.
Table “Friends” is shown below. Write output for (i) and (ii).

i. Select ucase(concat(name,”*”,city)) from friends where country like ‘Denmark’;


ii. Select mid(name,1,4) as “UID” from friends where country like ‘USA’;

22. Write the output of the following SQL queries:


i) SELECT TRUNCATE(8.975,2);
ii) SELECT MID(‘HONESTY WINS’,3,4);
iii) SELECT RIGHT(CONCAT(‘PRACTICES’,’INFORMATICS’),5);
iv) SELECT DAYOFMONTH(‘2015-01-16’);
23. Write the output of the following SQL queries :
(i) SELECT MID(‘BoardExamination’,2,4);
(ii) SELECT ROUND(67.246,2);
(iii) SELECT INSTR(‘INFORMATION FORM’,‘FOR’);
(iv) SELECT DAYOFYEAR(‘2015-01-10’);
24. Write output.
Table : Store
StoreId Name Location City NoOfEmployees DateOpened SalesAmount
S101 Planetfashion KarolBagh Delhi 7 2015-10-16 300000
S102 Trends Nehru Mumbai 11 2015-08-09 400000
Nagar
S103 Vogue Vikas Delhi 10 2015-06-27 200000
Vihar
S104 Superfashion Defence Delhi 8 2015-02-18 450000
Colony
S105 Rage Bandra Mumbai 5 2015-09-22 600000
(i) SELECT Name, length (name), left (name, 3) FROM Store where NoOfEmployees<3;

25. Write the output of the following SQL queries:


SELECT POW(INSTR(‘My_Database’,’_’),2);
26. Consider the table given below :
Write output.

(i) SELECT Name, LENGTH(Name) FROM Salesperson;

27. Identify Single Row functions of MySQL amongst the following :


TRIM(), MAX(), COUNT(*), ROUND()
28. Observe the given table named “Loan” carefully
and predict the output of the
following queries:
i. SELECT concat(left(file_no,2),
right(cust_name,2)) AS “ID” from loan where
Bank='ICUCI Ltd.';
ii. select round(loan_amt-
loan_amt*10/100) As "Discounted Payment" from
loan where loan_amt>700000;

29. Consider the table TEACHER given below. Write commands in SQL for (1) and output for (2) to (5)

i. To count the number of teachers in English department.


ii. SELECT MAX(Hiredate) FROM Teacher;
iii. SELECT DISTINCT(category) FROM teacher;
iv. SELECT COUNT(*) FROM TEACHER WHERE Category = "PGT"
v. SELECT Gender,AVG(Salary) FROM TEACHER group by Gender;

30. The ltem_No and Cost column of a table "ITEMS" are given below:
Based on this information, find the output of the following queries:
a) SELECT AVG(COST) FROM ITEMS;
b) SELECT COST +100 FROM ITEMS WHERE ITEM_NO > 103;

31. "PrincipaiName" is a column in a table "Schools". The SOL queries


SELECT count(*) FROM Schools;
and
SELECT count( Principal) FROM schools;
Give the result 28 and 27 respectively. What may be the possible reason for this? How many records are present in
the table-27 or 28?

32. Consider the table Projects given below. Write commands in SOL fori) and output for i) to iii)
i. To count the number of projects of cost less than 100000.
ii. SELECT SUM(Cost) FROM projects;
iii. SELECT ProjSize, COUNT(*) FROM Projects GROUP BY ProjSize;

33. Consider the table RESULT given below. Write output

(i) SELECT AVG(Stipend) FROM EXAM WHERE DIVISION=


"THIRD”;
(ii) SELECT COUNT(DISTINCT Subject) FROM EXAM;
(iii) SELECT MIN(Average) FROM EXAM WHERE Subject=
"English";

34. What is the purpose of ORDER BY clause in MySql ? How is it different from GROUP BY clause?

35. Consider the Table SHOPPE given below. Write command in MySql
for (i) and output for (ii) to (iii).

(i) To count distinct Company from the table.


(ii) Select Count(distinct (City)) from Shoppe;
(iii) Select MIN (Qty) from Shoppe where City="Mumbai";

36. Consider the table ‘PERSONS’ given below. Write commands in SQL for (i) to (iv) and write output for (i) to (iii).
(i) SELECT SUM(BasicSalary) FROM Persons Where Gender=’F’;
(ii) SELECT Gender,MIN(BasicSalary) FROM Persons
GROUP BY gender;
(iii) SELECT Gender,Count(*) FROM Persons GROUP BY
Gender;

37. There is a column HOBBY in a Table CONTACTS. The following two statements are giving different outputs. What
may be the possible reason ?
SELECT COUNT(*) FROM CONTACTS;
SELECT COUNT(HOBBY)FROM CONTACTS;

38. Consider the following table named "GYM" with details about fitness
items being sold in the store. Write output

(i) SELECT COUNT (DISTINCT (BRANDNAME) ) FROM GYM;


(ii) SELECT MAX (PRICE ) FROM GYM;

39. Consider the following table named 'SBOP" with details of


account holders. Write output.

(i) SELECT COUNT(*) FROM SBOP;

40. Given ‘Employee’ table as follows :

What values will the following statements return ?


SELECT COUNT(*) FROM Employee;
SELECT COUNT(Commission) FROM Employee;

41. Consider the table FLIGHT given below. Write output.

(i) SELECT MAX(NO_FLIGHTS) FROM FLIGHT;


(ii) SELECT START, COUNT(*) FROM FLIGHT GROUP BY
Start;

42. What will be the output of the following queries on the basis of Employee table:
(i)Select avg(Salary) from Employee;
(ii) Select Salary+100 from Employee where EmpId='A002';

43. Consider the following table named “GARMENT”. Write output

(i) SELECT COUNT(DISTINCT (SIZE)) FROM GARMENT;

(ii) SELECT AVG (PRICE) FROM GARMENT;

44. Consider the table ‘Teacher’ given below.


What will be the output of the following queries on the basis of
the above table:

(i)Select count(Department) from Teacher;


(ii)Select count(*) from Teacher;
45. (i) Name two Aggregate (Group) functions of SQL.
(ii) Consider the table :
Table : Company What output will be displayed by the
SID SALES following SQL statement ?
SELECT AVG(SALES) FROM Company;
S101 20000
S103 NULL
S104 10000
S105 15000
46. Consider the table ‘Hotel’ given below :
Table : Hotel Mr. Vinay wanted to display average salary of
EMPID Category Salary each Category. He entered the following SQL
statement. Identify error(s) and Rewrite the
E101 MANAGER 60000
correct SQL statement.
E102 EXECUTIVE 65000 SELECT Category, Salary FROM Hotel
E103 CLERK 40000 GROUP BY Category;
E104 MANAGER 62000
E105 EXECUTIVE 50000
E106 CLERK 35000
47. Explain why the following queries give different outputs on execution:
i. SELECT COUNT(ENAME) FROM EMP;
Output: 5
ii. SELECT Count(*) FROM EMP;
Output: 8

48. Kunal has entered the following SQL command on Table ‘STUDENT’ that has TotalMarks as one of the columns.
SELECT COUNT (*) FROM STUDENT;
The output displayed is 20.
Then, Kunal enters the following command :
SELECT COUNT (*) FROM STUDENT WHERE TotalMarks <100;
The output displayed is 15.
Then, Kunal enters the following command :
SELECT COUNT (*) FROM STUDENT WHERE TotalMarks >= 100;
He predicts the output of the above query as 5. Do you agree with Kunal ? Give reason for your answer.
49. Consider the table given below :
Write command for (i) and output for (ii)
(i) To display Area along with number of Salespersons working
in that area.
(ii) SELECT Area, COUNT (*) FROM Salesperson GROUP BY Area
HAVING COUNT (*) > 1;

50. Observe the given table named “Loan” carefully and


predict the output of the
following queries:
select count(file_no)-count(loan_amt) from loan;

51
What are the libraries used in Python.Explain how are libraries called in Python?

52 Write short note on i)Pandas library


ii)Matplotlib library

53 What is the extension of Python? Explain import in python.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy