0% found this document useful (0 votes)
36 views35 pages

Bhavesh ISM Practical File

The document explains various SQL queries and their outputs. It contains questions from Q1 to Q46 explaining concepts like CREATE TABLE, SELECT, WHERE, ORDER BY, INSERT, UPDATE, DELETE queries along with table structures and sample outputs.

Uploaded by

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

Bhavesh ISM Practical File

The document explains various SQL queries and their outputs. It contains questions from Q1 to Q46 explaining concepts like CREATE TABLE, SELECT, WHERE, ORDER BY, INSERT, UPDATE, DELETE queries along with table structures and sample outputs.

Uploaded by

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

A

ISM Lab
Practical File

Submitted By: - Submitted To: -


Name: - Bhavesh Jaiswal Name: - Dr. Ajay Sir
Enrollment No.: - 03819301721 (Assistant Professor)
Course: - BBA 5th Semester
Subject: - ISM

Kasturi Ram College of Higher Education NARELA, DELHI -110040


(Affiliated to Guru Gobind Singh Indraprastha University)
Q1 Explain the create emp and dept file with help of query?
Query
create table dept
(deptno number primary key,pname text,loc text);
Solution
Query of emp
create table
emp
(empno number primary key,
ename text,job text,mgr number,hiredate date,sal
number,comm number,deptno number references dept (
deptno));
output
Dept table with data
Emp file with data
Q.2 Explain Query of select from emp and output?
Query
select * from emp
output

Q3 Explain Query of select ename sal from emp and output?


Query
select ename,sal from emp;
output

Q4 Explain Query of select ename sal sal+500 from emp and


output?
Query
select ename , sal , sal+500 from emp ;
output
Q5 Explain Query of select ename,sal from emp where
sal>1000 and output?
Query
select ename,sal from emp where sal>1000 ;
output
Q6 Explain Query of select ename,sal from emp where
ename=’ramesh’and output?
Query
select ename,sal from emp where ename=’ramesh’;
output
Q7 Explain Query of select ename,hiredate from emp
where hiredate>= ‘09-april-10and output?
Query
select ename,hiredate from emp where " hiredate>= ‘09-april-
10' ; "
output
Q8 Explain Query of select from emp where
deptno<>15; and output?
Query
select * from emp where deptno<>15 ;
output

Q9 Explain Query of select from emp where sal


between 10000 and 30000 and show output?
Query
select * from emp where sal between 10000 and 30000 ;

output
Q10 Explain Query of select from emp where
job in(‘clerk’,’manager’,’salesman’)and show
output?
Query
select * from emp where job in(‘clerk’,’manager’,’salesman’);
output

Q11 Explain Query of select from emp where


ename like’s%’and show output?
Query
select* from emp where ename like’s*’;
output
Q 12 Explain Query of select from emp where ename like’---
d’and show output?
Query
select * from emp where ename like '*h' ;
output

Q13 Explain Query of select from emp where ename


like’?o*’and show output?
Query
select * from emp where ename like '?o*';
output
Q 14 Explain Query of select from emp where comm. Is null
And show output?
Query
select * from emp where comm is null ;
output
Q15 Explain Query of select from emp where deptno=10 And
sal> 15000 show output?
Query
select * from emp where deptno=15 And sal>15000;
output

Q 16 Explain Query of select from emp where deptno=15 or


deptno=35 and show output?
Query
select * from emp where deptno=15 or deptno=35 ;
output
Q 17 Explain Query of select from emp where comm. Is
not null and show output ?
Query
select * from emp where comm is not null;
output
Q 18 Explain Query of select from emp where job not in
(clerk,salesman) and show output?
Query
select * from emp where job not in ('clerk','salesman') ;
output

Q 19 Explain Query select from emp where (job=salesman


or job=clerk) and sal >15000 and show output?
Query
select * from emp where( job='salesman' or job ='clerk') and
sal>15000;
output
Q 20 Explain the Query of select from emp order by ename
and show output?
Query
select * from emp order by ename ;
output
Q 21 Explain Query of select from emp order by sal desc and
show the output?
Query
select * from emp order by sal desc;
output

Q22 Explain Query of select from emp order by ename sal


desc and show the output?
Query

select *from emp order by ename , sal desc ;


Output

Q 23 Explain Query of select from emp order by dept no.asc


sal desc and show the output?
Query
select * from emp order by deptno.asc ,sal desc ;
output
Q 23 Eplain Query of add column in dept table?
Query
ALTER table dept add phone number;
output

Q 24 Explain Query of alter table dept drop column phone?


Query
Alter Table dept
drop column phone;
output
Q25 Explain Query of delete from emp where sal>15000 and
show output?
Query

delete from emp where sal>15000 ;


ouput

Q26 Explain query of insert into dept values (‘sales’,so,’mumbai’) and show Output
Query
insert into dept values ( so , ‘sales’ , ’mumbai’);
output
Q 27 Explain Query of select lower ename from emp?
Query
select lcase(ename) from emp;
output

Q 28 Explain Query of select len (ename) from emp?


Query
select len (ename) from emp;
output

Q 29 Explain Query of select sum (sal) from emp?


Query
select sum (sal) from emp;
output
Q 30 Explain Query of select sum (sal) from emp where
deptno=15?
Query
select sum (sal) from emp where deptno=25;
output

Q 31 Explain Query of select max(sal) from emp?


Query
select max(sal) from emp;
output
Q 32 Explain Query of select min(sal) from emp?
Query
select min(sal) from emp;
output
Q 33 Explain Query of select avg (sal) from emp?
Query
select avg (sal) from emp;
output

Q 34 Explain Query of select count(*) from emp?


Query
select count(*) from emp;
output
Q 35 Explain Query of select count (*) from emp where deptno=25
Query
select count(*) from emp where deptno=25;
output

Q36 Explain Query of select ename,sal from emp where sal


=’(select max (sal) from emp)?
Query
select ename,sal from emp where sal =(select max (sal) from
emp);

output
Q 38 Explain query of select ename,pname from emp ,dept
where emp.deptno=dept.deptno?
Query
select ename,pname from emp ,dept
where emp.deptno=dept.deptno;

Output
Q 39 Explain Query of Non-Null Constraint with the help of table.

Quary
CREATE TABLE EMP (
EMPID int NOT NULL,
EMPLastName varchar(255) NOT NULL,
EMPFirstName varchar(255) NOT NULL,
Age int);

Output

Q40 Explain Add Constraint With the help of Alter Table Statement .
Quary
ALTER TABLE Emp
Add column Departno Number, PhoneNo Number;
Output :-
Q 41 Explain Quary of Delete/Drop a Column With the help of Table.

Quary
ALTER TABLE Emp
Drop Column Phoneno;

Output

Q 42 Explain Delete Statement With the help of Example.

Quary
Delete From Emp where Salary<15000;

Output:-
Q 43 Insert The Data with the help of quary

Quary:-
Insert into Emp Values ( 12222,'Mithlesh',20,'Goa',90000);

Output:-

Q 44 Changing Data with the help of quary.

Quary:-
Update emp
set salary=100000
where ename='Bhavesh';
Q45 Explain NVL Function with the help of Quary.

Table:-

Quary:-
If we write this Quray

SELECT ename, salary, (salary+ comm) FROM emp;


Then Output will be:-

Notice that if any column value in an expression is NULL , The result is Null.

Quary:-
SELECT ename ,salary, (salary+ IIF(IsNull(comm), 0, comm))
FROM emp;
Output:-

In the above example the NVL Function is used to convert all Null Values of comm
Column to zero & Then evalaute the Expresion.

Q46 Explain where function with the help of qauary.

Quary:-
SELECT ename ,salary from emp
where comm=4000

Output:-

You might also like