You are on page 1of 70

ST.

ANSELM’S NORTH CITY SCHOOL, JAIPUR

PRACTICAL FILE
INFORMATICS PRACTICES
(CODE NO. - 065)
SESSION – 2021-22

SUBMITTED TO:- MS. KAVITA KANWAR


SUBMITTED BY:- RAJAT SHARMA
CLASS:- 12TH-B
ROLL NO :- 40
CERTIFICATE

This is to certify that Rajat Sharma has


successfully completed the practical work
entitled in the subject Informatics Practices
(065) laid down in the regulations of CBSE for
the purpose of Practical Examination in Class
XII to be held in St. Anselm’s North City
School, Jaipur.

INTERNAL EXAMINER EXTERNAL EXAMINER


ACKNOWLEDGEMENT

Apart from the efforts to me, the success of


any project depends largely on the
encouragement and guidelines of many
others. I take this opportunity to express my
gratitude to the people who have been
instrumental in thesuccessful completion of
this project.
I express deep sense of gratitude to almighty
God for giving me strength for the successful
completion of the project.
I express my heartfelt gratitude to my parents
for constant encouragement while carrying
out this project.
My sincere thanks to Ms. Kavita Kanwar, a
guide, Mentor, who critically reviewed my
project and helped in solving each and every
problem, occurred during implementation of
the project.
INDEX
S.NO. TITLE DATE Page Teacher’s
No. Sign/Remarks
A. Data Management (SQL Queries) (i)
1. Create a database 07-07-2021 09
2. Create a table 07-07-2021 09
3. Insert values in rows 07-07-2021 10
4. Delete a column 07-07-2021 12
5. Update a column 07-07-2021 12
6. Empty DataFrame 08-07-2021 13
7. DataFrame from Series 08-07-2021 14
8. Indexing in DataFrame 08-07-2021 14
9. Empty Series 08-07-2021 15
10. Series using list 08-07-2021 15
11. Series using range method 08-07-2021 19
12. Single and multiple values in 08-07-2021 20
Series
13. Slicing, indexing, accessing from 08-07-2021 21
series
14. Usage of loc and iloc 08-07-2021 22
15. Series from scalar values 08-07-2021 23
16. Delete a column 08-07-2021 23
17. Demonstrating Aggregate Func. 08-07-2021 24
18. Demonstrating Math Func. 08-07-2021 25
19. Demonstrating Text Func. 08-07-2021 27
20. Demonstrating Date Func. 08-07-2021 33
21. Displaying the details of the table 08-07-2021 36
on a given condition.
22. Using the key word ’DISTINCT’. 08-07-2021 38
23. Using group by. 08-07-2021 40
24. Using the having clause. 08-07-2021 41
25. Group by with order by. 08-07-2021 42
26. Group by with having and where 08-07-2021 42
clause.
27. Adding primary key. 08-07-2021 43
28. Deleting a column. 08-07-2021 43
29. To remove primary key. 08-07-2021 44
30. To increase marks. 08-07-2021 44
31. Changing data type of column. 08-07-2021 45
32. Deleting the table . 08-07-2021 46
33. Creating a new table product. 08-07-2021 46
34. Creating a table LOAN. 08-07-2021 48
35. Displaying the details of the table 08-07-2021 49
on a given condition.
36. Displaying the details of the table 08-07-2021 51
on a given condition.
37. Displaying the details of the table 08-07-2021 51
on a given condition.
38. Displaying the details of the table 08-07-2021 52
on a given condition.
39. Displaying the details of the table 08-07-2021 52
on a given condition.
40. Displaying the details of the table 08-07-2021 53
on a given condition.
41. Displaying the details of the table 08-07-2021 54
on a given condition.
42. Displaying the details of the table 22-07-2021 54
on a given condition.
43. Updating the table. 22-07-2021 55

44. Displaying the details of the table 22-07-2021 55


on a given condition.
45. Deleting the details of the table 22-07-2021 56
for a specific condition.
46. Altering the table. 22-07-2021 56
47. Displaying the details of the table 22-07-2021 57
on a given condition.
48. Finding the average installments. 22-07-2021 57

49. Finding the total loan amount. 22-07-2021 58

50. To find total no. of loans taken 22-07-2021 58


after 2008.
51. Displaying the details of the tables 31-07-2021 59
student and sports.
52. Displaying the details of the table 31-07-2021 60
on a given condition.
53. Displaying the details of the table 31-07-2021 61
on a given condition.
54. Displaying the details of the table 31-07-2021 61
on a given condition.
55. Displaying the details of the table 31-07-2021 62
on a given condition.
56. Displaying the details of the table 31-07-2021 62
on a given condition.
57. Displaying the details of the table 31-07-2021 62
on a given condition.
58. Displaying the details of the table 31-07-2021 63
on a given condition.
59. Displaying the details of the table 31-07-2021 66
on a given condition.
60. Displaying the details of the table 31-07-2021 69
on a given condition.
DATA MANAGEMENT
(SQL QUERIES)
1. To create a database.

Create database student_123;

2. To create student table with student


id, class, section, gender, name, dob
and marks as attributes
Where the student is primary key.
create table student(student_id integer primary key,
class integer,
section char (1),
gender char(1),
name varchar(50),
dob date,
marks float(10,2));

3. To insert the details of at least 10


students in the student table.
insert into student values(1,12,'b','m','rajkumar','2003-
03-03',90),

(2,12,'a','m','ravi','2003-10-06',80),

(3,10,'a','m','naman','2004-02-08',86),

(4,12,'a','m','ram','2003-10-01',80),

(5,12,'c','m','arjun','2004-09-23',83),

(6,10,'c','m’,'ayush','2004-04-19',94),

(7,12,'a','m','pratik','2003-12-09',92),

(8,12,'b','m','tarun','2003-12-03',80),

(9,12,'a','m','rishi','2004-10-03',79),

(10,10,'a','m','ritvik','2002-02-07',90);
4. To delete the details of a particular
student from the above table.

]
delete from student where student_id=8;

5. To increase marks by 5% whose


Student id is more than 20.

update student set marks=1.05*marks where


student_id>20;
6. To display student_id, name and
marks of those students who are
scoring marks more than 50.

select student_id,name,marks from student


where marks>50;
7. To find the average of the marks from
the student table.

select avg(marks) as "average marks"

-> from student;

8. To find the no. of students who are


from section A.

select count(*) from student where section="a";


9. To add a new column emal in the
above table with appropriate
Data type.

alter table student

-> add email varchar(30);

10. To add the email ids of each student


in the previously created
Email column.
update student set email='raj200103@gmail.com'
where student_id=2;

update student set email='vi033@gmail.com'


where student_id=3;

update student set email='nam3@gmail.com'


where student_id=4;

update student set email='ram45@gmail.com'


where student_id=5;

update student set email='ayush905@gmail.com'


where student_id=6;

update student set email='drekdj3@gmail.com'


where student_id=7;

update student set email='fhhjsa@gmail.com'


where student_id=8;

update student set email='indiajd@gmail.com'


where student_id=9;
update student set email='alshh@gmail.com'
where student_id=10;

11. To display the information all the


students , whose name starts with ‘A’.

select name from student where name like "a%";


12. To display student_id , name ,dob of
those students who are between
‘2005-01-01’ and ‘2005-12-31’.

select student_id, name from student where

dob between'2005-01-01' and '2005-12-31';


13. To display student_id , gender
,name, dob, marks, email in descending
order of their marks.

select student_id,gender,name,dob,marks,email from


student order by marks desc;
14. To display student_id, name ,dob
,marks ,email of
Those male students in ascending order
of their name.

select student_id,name,dob,marks,email from student


where gender='m' order by name asc;
15. To display the unique section
available in the table.

select student_id from student;

16. Delete the details of a particular


student in the above table.
Delete from student where student_id=8;
17. Find a min, max, sum and average of
the marks in a student marks table.

Select min(marks) from student;

Select max(marks) from student;


Select avg(marks) from student;

Select sum(marks) from student;

18. Write a command to demonstrate


math function.
POWER()

Select power(10,3)”Raised”;

ROUND()

Select round(11.478,1)”Round”;
MOD()

Select mod(10,3)”Modulus”;

19. Write a command to demonstrate


math function.

UPPER()/UCASE()

Select upper(‘united states of america’)”UPPERCASE”;


LOWER()/LCASE()
select lower('Mexico')as"lowercase";

MID()/SUBSTRING()/SUBSTR()
select substr('ABCDEFGHIJK',4,7)"Subs";

LENGTH()
select length(‘MALDIVES’)”length in charecters”;
LEFT()
select left(‘MALDIVES’,2);
RIGHT()

select right(‘MALDIVES’,2);

INSTR()

select instr('karl jacob','co')as"INSTRING";


LTRIM()

select LTRIM(' jacob');


RTRIM()

select RTRIM( 'jacob' );

TRIM()

select TRIM( 'jacob' );


20. Write a command to demonstrate
DATE function.

NOW()
select NOW();

DATE()
select DATE('2021-07-30 01:02:03');
MONTH()
select MONTH('2021-07-30');

MONTHNAME()
select MONTHNAME('2021-07-30');
YEAR()
select YEAR('2021-07-30');

DAY()
select DAY('2021-07-30');
DAYNAME()
select DAYNAME('2021-07-30');

21. Write a SQL function which will


perform the following operations:
i. To display the name of the month of
the current date.
ii. To remove spaces from the
beginning and end of a string, ‘
Panorama ’.
iii. To display the name of the day (eg.
Friday or Sunday) from your
date of birth, dob.
iv. To compute the remainder of
division between two numbers, n1
and n2.
Select monthname(date(now()));

Select trim(‘panorama’);

select dayname(date(dob)) from student ;


Select Mod(99,23);

22. Command for using keyword


DISTINCT.
select*from student;
select distinct class from student;
23. Command for using GROUP BY.

select*from student;

select name, marks, section from student GROUP BY


section;
24. Command for using HAVING clause.
select*from student;

select name, marks, section from student GROUP BY


name HAVING marks>80;
25. Command for using GROUP BY with
order by.
select name, marks, section from student GROUP BY
section order by marks desc;

26. Command for using GROUP BY and


having clause with WHERE clause.
select marks,name,class from student where class=12
group by name having marks<90;
27. Command for adding primary key.

alter table student add primary key(student_id);

28. Command to delete a coloumn.

alter table student drop student_id;


29. Command to remove primary key.

alter table student drop primary key;

30. Command to increase marks.

select*from student;
update student set marks=marks*2;

select*from student;

31. Command to change data type of


an existing coloumn.

alter table student modify marks decimal(8,2);


32. Command to delete table.

drop table student;

33. Create a table product and insert a


record in it.

create table product(pno integer primary key,


pname varchar(50)not null,
dop date,
company varchar(20),
price decimal(8,4),
Oty varchar(20)

);

insert into product values(1001,’buds’,’2021-04-


21’,’JBL’,3599.50,500),
(1002,’headphone’,’2020-12-
01’,’SENNHISER’,8000.00,100),
(1003,’mic’,’2020-10-05’,’AKG’,4500.00,250),
(1004,’mic_stand’,’2019-02-
16’,’YAMAHA’,9000.00,350),
(1005,’tv’,’2021-12-16’,’LG’,2500.00,200),

(1006,’phones’ ,’2021-11-26’,’ASUS’,9500.00,400);
34. Create a table loan with details
Acc_No , Cust_Name, Loan_Amt ,
Installment , Int_rate , Start_Date.

Create table loan (Acc_No int primary key,

Cust_Name varchar(30),

Loan_Amt int, Installment int,

Int_rate float(5,3),

Start_Date date);
35. Write a command to display
acc.no., customer name and loan amt.
of all loans.

Insert into loan values(1,'RAKESH


GUPTA',300000,36,12.0,'2009-07-19');

Insert into loan values(2,’JAIVARDHAN RAJPUT’,


500000,12,13.2,’2011-12-30’);

Insert into loan values(3,’R.K.SINGHANYA’,


100000,15,10.05,’2012-10-30’);

Insert into loan values(4,’DIVYA MATHUR’,


250000,10,12.0,’2011-10-07’);
Insert into loan values(5,’ALICE ROBBIE’,
750000,48,10.00,’2014-03-23’);

select Acc_No,Cust_Name,Loan_Amt from loan;


36. Write a command to display the
details of all loans with less than 40
installments .

Select * from loan where Installment<40;

37. Write a command to display the


details of all loans whose rate of
installments is Null.

Select * from loan where Int_rate=null;


38. Write a command to display the
amount of various loans, a loan
amount should appear once.

Select distinct(Loan_Amt) from loan;

39. Write a command to display the


customer name and loan amt. for all
the loans which do not have
installment 36.
Select Cust_Name , Loan_Amt from loan where
Installment<>36;

40. Write a command to display the


details of all the loans whose loan amt
is in the rate 400000 and 500000 .

select* from loan where Loan_Amt<500000 and


400000<Loan_Amt ;
41. Write a command to display the
account number ,customer name and
loan amount of all the loans for which
customer name is ‘sharma’.

select Acc_No ,Cust_Name ,Loan_Amt from loan where


Cust_Name like’ %sharma’ ;

42. Write a command to display the


details of all the loans in ascending
order of their loan amt .

select* from loan order by Loan_Amt ;


43. Write a command to put the
interest rate11.50% for all the whose
interest rate is null.
Update LOAN set Int_rate=11.50 where Int_rate is null;

44. Write a command to display the


details of all the loans whose
installment is below 40 and loan
amount above 250000.
Select* from LOAN where Installment<40 and
Loan_Amt>250000;

45. Delete the details of all the loans


whose start date is before 2008.

Delete from LOAN where year(Start_Date)<2008;

46. Add a column category of type


char(1) in the table loans.
Alter table LOAN add Category char(1);

47. Display the maximum loan whose


interest rate 12%.
Select max(Loan_Amt) from LOAN where Int_rate=12;

48. Find average installment .

Select avg(Installment) from LOAN ;


49. Find the total loan amount .
Select sum(Loan_Amt) from LOAN ;

50. To count total no. of customers


whose loan started after 2008.

select count(Start_Date) from LOAN where


year(Start_Date)>2008;
51. Display the details of the tables
student and sports .

Select * from student;


Select * from sports;

52. Display the highest and lowes class


from the table student .

Select max(class) ,min(class) from student;


53. Display the number of student in
each class from the table student .

Select count(class),class from student group by class;

54. Display the number of student with


each coach.
Select count(*),Coach_name from sports group by
Coach_name;
55. Display the admission no., name ,
class , grade and game of the student
whose grade in sports table is A.

Select st.Adm_no ,st.name ,st.class ,sp.Grade ,sp.Game


from student st, sports sp where
st.Adm_no=sp.Adm_no and sp.Grade =’A’;
56. Display the average rate of south
Indian item.

select avg(rate) from item where Category='SOUTH


INDIAN' ;

57. Display the number items in each


category.
Select count(*),Category from item group by Category;
58. Consider the table given below and
answer the following question.

58.1. Display the details of all the


employees whose grade is null.
select * from Employee where grade='NULL';

58.2. Display the details of all the


employees who getting salaries more
than 35000 in the department 30.
select * from Employee where Salary>35000 and
Dept=30;

58.3. Display the names and salaries of


all the employess who are neither
working in west zone nor in center
zone.
select Name, Salary from Employee where Zone!=
'West'and Zone!='Center';

58.4. Display the average salaries of


grade ’a’ employees.

Select avg(Salary) from Employee where grade=’A’;

58.5. Display the total number of


employees in each department.

Select count(*), Dept from Employee group by Dept;

58.6. Display the details of all the


employees in the ascending order of
their salaries.
select* from Employee order by Salary asc;

58.7. Display the name, salary and age


of all the employees who have ‘a’ in
their name.

Select Name, Salary, Age from Employee where Name


like”%a%”;

59. Consider the table TEACHER and


answer the following question.

59.1. Display the name and salary of


male teacher in math department.

Select NAME,SALARY from TEACHER where SEX=’M’


and DEPARTMENT=’MATH’;

59.2. Display the number of teachers in


each department department.
Select count(*),DEPARTMENT from TEACHER group by
DEPARTMENT;
59.3. Display the details of all the
teachers who are getting salaries less
than 25000 in comp department.
Select*from TEACHER where SALARY<25000 and
DEPARTMENT=COMPUTER;

59.4. Display the average salary and


total salary of teacher of history
department.
Select avg(SALARY) , total(SALARY) from TEACHER
where DEPARTMENT=HISTORY;

59.5. Display the name, age and


department of teachers whose name
contains h as the second character.
Select NAME,AGE,DEPARTMENT from TEACHER where
NAME like ’_C%’;

59.6. Display the Name ,department ,


salary, age and sex of teacher in
descending order of their salary.
Select NAME, DEPARTMENT ,SALARY, AGE, SEX from
TEACHER order by SALARY desc;

59.7. Display the details of the


teachers who joined in the year 2007.
Select * from TEACHER where
year(DATEOFJOIN)=’2007’;

60. Consider the table TEACHER and


answer the following question

60.1. Display the details of the female


teachers of history department.
Select NAME,SALARY from TEACHER where SEX=’F’ and
DEPARTMENT=’HISTORY’;
60.2. Display the name and date of
join of teachers according to their date
of join.
Select NAME, DATEOFJOIN from TEACHER order by
DATEOFJOIN;
60.3. Display the name and age of male
teachers.
Select NAME, AGE from TEACHER where SEX=’M’;
60.4. Display the department and total
salary of each department.
Select DEPARTMENT ,total(SALARY) from TEACHER
group by DEPARTMENT;

60.5. Display the department ,min


salary and max salary of each
department.
Select DEPARTMENT ,min(SALARY),max(SALARY) from
TEACHER group by DEPARTMENT;

60.6. Display the details of the


teachers whose ages are in the range
31 to 34.
Select * from TEACHER where AGE>31 and AGE<34;
60.7. Display the details of the
teachers whose name starts with ‘s’.
Select * from TEACHER where NAME like’S%’;

You might also like