You are on page 1of 27

PRACTICAL FILE

ON

ISM LAB

Submitted in the partial fulfillment of the degree

of
Bachelor of Business Administration

(2021)

SUBMITTED BY:

Name :-

ENROLLMENT NO. :-

Under the guidance of

Mr. Devansh Raghav

(ASST. PROFESSOR, BBA – 2nd Shift (IT))

Ideal Institute of Management & Technology


(16 X, Karkardooma Institutional Area, Delhi-92)

(AFFILIATED TO GURU GOBIND SINGH INDRAPRASTHA UNIVERSITY, DELHI)


CERTIFICATE

This is to certify that Practical file entitled, “ISM LAB” is bonafide work carried out by
(NAME) student of BBA, Ideal Institute of Management and Technology (affiliated to GGSIP
University, Delhi) in partial fulfillment of the requirement for the award of degree of Bachelor
of Business Administration, under my guidance & Direction. To the best of my knowledge and
belief the data & information presented by her in the Practical has not been submitted for the
award of any other degree.

MR DEVANSH RAGHAV
(Asst. Professor, BBA-2nd Shift (IT))
ACKNOWLEDGEMENT

I am writing this practical file for the program of Bachelor of Business Administration on “ISM
LAB” for Ideal Institute of Management & Technology Affiliated to Guru Gobind Singh
Indraprastha University.
It has been a great challenge but a plenty of learning and opportunities to gain a huge amount
of knowledge on the way of writing this Practical file. I could not have completed my file
without the constant guidance of Asst. Prof. Mr. Devansh Raghav, my faculty, who helped me
along the way and was always prepared to give me feedback and guidelines whenever I needed
it.

Name: Signature:
Enrollment no.: Date:
INDEX

S. NO. PARTICULARS PAGE NO.

1. INTRODUCTION TO MY SQL 1.
SQL theory

2. PRACTICAL 1: DDL COMMANDS 3.


. DDL theory
Query 1: Write a query to create table student
Query 2: Write a query to add columns – Marks
Query 3: Write a query to destroy the table and all the data held
in it.

3. PRACTICAL 2: DML COMMANDS 6.


DML theory
Query 4: Write a query to insert data in table student
Query 5: Write a query to update and change the content of field
name to Charu and subject to PCM having roll no is 002
Query 6: Write a query to delete from table where roll no is
more than 003

4. PRACTICAL 3: DCL & DQL COMMANDS 9.


DCL & DQL theory
QUERY 7: a)Write a query to view the data from table Student
b) Write a query to view roll no and name from table
student where subject is commerce

5. PRACTICAL 4: LOGICAL OPERATORS 11.


Logical operators theory
Query 8: Write a query to retrieve the contents of the columns roll
no, name, subject from the table student where marks are between
90 and 100
Query 9: Write a query to retrieve all fields of the table student
where roll no has the value 003 or 005
Query 10: Write a query to retrieve all fields of the table student
who do not have commerce or humanities as the subject

6. PRACTICAL 5: RANGE SEARCHING OPERATORS 14.


Range searching operator theory
Query 11: Write a query to retrieve the contents of the columns
roll no, name, subject from the table student where marks are
between 80 and 90 both inclusive
Query 12: Write a query to retrieve all information about students
where the second character of name is „a‟
Query 13: Write a query to retrieve the contents of the columns
roll no, name, subject from the table student where name is either
Akash or Naira or Tanya

7. PRACTICAL 6: ORDER BY CLAUSE 17.


Order by clause theory
Query 14: Write a query to retrieve all rows from student and
display this data sorted on the value contained in the field roll no
in :
a) Ascending order
b) Descending order

8. PRACTICAL 7: AGGREGATE FUNCTIONS 19.


Aggregate functions theory
Query 15: Write a query to find the average of the marks column
Query 16: Write a query to find the sum of the marks column
Query 17: Write a query to count the number of students with
marks more than 85
Query 18: Write a query to retrieve the information of student
having:
a) Maximum marks
b) Minimum marks
INTRODUCTION TO SQL

-6-
PRACTICAL 1
DDL COMMANDS
(Data definition language)

a. DDL changes the structure of the table like creating a table, deleting a table, altering a
table, etc.
b. All the command of DDL are auto-committed that means it permanently save all the
changes in the database.
c. Some commands that come under DDL are:
• CREATE
It is used to create a new table in the database.
• ALTER
It is used to alter the structure of the database. This change could be either to
modify the characteristics of an existing attribute or probably to add a new
attribute.
• DROP
It is used to delete both the structure and record stored in the table.
• TRUNCATE
It is used to delete all the rows from the table and free the space containing the
table.

-7-
QUERY 1: Write a query to create table student.

To create table, we use create command. Syntax of create command is –

CREATE TABLE tablename (columnname datatype, …)

QUERY 2: Write a query to add columns – Marks.

To add columns to the table, we use alter command. Syntax of alter command is –

ALTER TABLE tablename ADD (columnname (columndefinition));

QUERY 3: Write a query to destroy the table and all the data held in it.

To destroy the table and all the data held in it, we use drop command. Syntax of drop
command is –

DROP TABLE tablename;

-8-
-9-
PRACTICAL 2
DML COMMANDS
(Data manipulation language)

a. DML commands are used to modify the database. It is responsible for all form of
changes in the database.
b. The command of DML is not auto-committed that means it can't permanently save all
the changes in the database. They can be rollback.
c. Some commands that come under DML are:
• INSERT
It is used to insert data into the row of a table.
• UPDATE
It is used to update or modify the value of a column in the table.
• DELETE
It is used to remove one or more row from a table.

- 10
-
QUERY 4: Write a query to insert data in table student.

To insert data in table, we use insert command. Syntax of insert command is -

INSERT INTO tablename


(col1, col2, col3,.... col N)
VALUES (value1, value2, value3, .....valueN);

QUERY 5: Write a query to update and change the content of field name to ……… and
subject to ………. having roll no is 002.

To update the content, we use update command. Syntax of update command is –

UPDATE table_name SET [column_name1= value1,. . column_nameN = valueN] [WHERE


CONDITION];

- 11
-
QUERY 6: Write a query to delete from table where roll no is more than 003.

To delete from the table, we use delete command. Syntax of delete command is –

DELETE FROM table_name [WHERE condition];

- 12
-
PRACTICAL 3:
DCL & DQL COMMANDS
(Data Control language & Data Query language)

a. DCL commands are used to grant and take back authority from any database user.
b. Here are some commands that come under DCL:
• GRANT
It is used to give user access privileges to a database.
• REVOKE
It is used to take back permissions from the user.
c. DQL is used to fetch the data from the database.
a. It uses only one command:
• SELECT
It is the same as the projection operation of relational algebra. It is used to
select the attribute based on the condition described by WHERE clause.

- 13
-
QUERY 7:

a) Write a query to view the data from table Student.

To view all the data, we use select command. Syntax of view command is –

Select * from tablename;

b) Write a query to view roll no and name from table student where subject is
commerce.

To select a particular column, we use the following syntax –

SELECT columnname
FROM tablename
WHERE conditions;

- 14 -
PRACTICAL 4
LOGICAL OPERATORS

The logical operators used in sql are:

• AND Operator
It displays only those records where both the given conditions evaluates to True.
• OR Operator
It displays the records where either one of the conditions evaluates to True.
• NOT Operator
It can be used to put before any conditional statement to select rows for which that
statement is false.

- 15 -
QUERY 8: Write a query to retrieve the contents of the columns roll no, name, subject
from the table student where marks are between 90 and 100.

To retrieve the content of he columns roll no, name, subject from the table student where
marks are between 90 and 100, we use AND operator. Syntax of AND operator is –

Select column 1, column 2….


From tablename
Where condition 1 AND condition 2;

QUERY 9: Write a query to retrieve all fields of the table student where roll no has the
value 003 or 005.

To retrieve all fields of the table student where roll no has the value 003 or 005, we use OR
operator. Syntax of OR operator is –

Select * From tablename


Where condition 1 OR condition 2;

- 16 -
QUERY 10: Write a query to retrieve all fields of the table student who do no have
commerce or humanities as the subject.

To retrieve all fields of the table student who do no have commerce or humanities as the
subject, we use NOT operator. Syntax of NOT operator is –

Select * From tablename


Where NOT condition 1 OR condition 2;

- 17 -
PRACTICAL 5
RANGE SEARCHING OPERATORS

• BETWEEN Operator
It allows you to select only rows that are within a specific range.
• LIKE Predicate
It allows you to match on similar values rather than exact ones.
• IN Predicate
It allows you to specify a list of values that you'd like to include in the results.

- 18 -
QUERY 11: Write a query to retrieve the contents of the columns roll no, name, subject
from the table student where marks are between 80 and 90 both inclusive.

To retrieve the contents of the columns roll no, name, subject from the table student where
marks are between 80 and 90 both inclusive, we use BETWEEN operator. Syntax of
BETWEEN operator is –

Select column 1, column 2….


From tablename
Where columnname BETWEEN value 1 AND value 2;

QUERY 12: Write a query to retrieve all information about students where the second
character of name is ‘a’.

To retrieve all information about students where the second character of name is „a‟, we use
like operator. Syntax of like operator is –

Select * from tablename


Where columnname LIKE condition

- 19 -
QUERY 13: Write a query to retrieve the contents of the columns roll no, name, subject
from the table student where name is either Akash or Naira or Tanya.

To retrieve the contents of the columns roll no, name, subject from the table student where
name is either Akash or Naira or Tanya, we use IN operator. Syntax of IN operator is -

Select columnname(s)
From tablename
Where columnname IN (value1, value2….);

- 20 -
PRACTICAL 6
ORDER BY CLAUSE

• ORDER BY
It allows you to specify a list of values that you'd like to include in the results.

- 21 -
QUERY 14: Write a query to retrieve all rows from student and display this data sorted
on the value contained in the field roll no in:

a) Ascending order

To retrieve all rows from student and display this data sorted on the value contained in the
field roll no in ascending order, we use order by clause. Syntax of order by clause is -

Select * from tablename ORDER BY columnname1, columnname2 [ASC];

b) Descending order

To retrieve all rows from student and display this data sorted on the value contained in the
field roll no in descending order, we use order by clause. Syntax of order by clause is -

Select * from tablename ORDER BY columnname1, columnname2 [DESC];

- 22 -
PRACTICAL 7
AGGREGATE FUNCTIONS

SQL offers five suit-in aggregate functions:

• Average: AVG
It returns the average of the values in a specified column.
• Minimum: MIN
It returns the smallest value in the specified table field.
• Maximum: MAX
It returns the largest value from the specified table field.
• Total: SUM
It returns the sum of all the values in the specified column.
• Count: COUNT
It returns the total number of values in the specified field.

- 23 -
QUERY 15: Write a query to find the average of the marks column.

To find the average marks, we use average function. Syntax of average function is –

Select AVG columnname


From tablename
Where condition;

QUERY 16: Write a query to find the sum of the marks column.

To find the sum, we use sum function. Syntax of sum function is –

Select SUM columnname


From tablename
Where condition;

- 24 -
QUERY 17: Write a query to count the number of students with marks more than 85.

To find the number of students with marks more than 85, we use count function. Syntax of
count function is –

Select COUNT
from tablename
where condition;

QUERY 18: Write a query to retrieve the information of student having:

a) Maximum marks

To retrieve the information of student having maximum marks, we use MAX


function. Syntax of MAX function is –

Select MAX (columnname)


From tablename
Where condition;

- 25 -
b) Minimum marks

To retrieve the information of student having maximum marks, we use MIN function.
Syntax of MIN function is –

Select MIN (columnname)


From tablename
Where condition;

- 26 -
- 27 -

You might also like