Professional Documents
Culture Documents
PRACTICAL -2
Aim:
Theoretical Description:
In databases, data retrieval is the process of identifying and extracting data from a
database, based on a query provided by the user or application.
It enables the fetching of data from a database in order to display it on a monitor
and/or use within an application.
An SQL query can contain three types of clauses, the select clause, the from
clause, and the where clause. The role of each clause is as follows:
The select clause is used to list the attributes desired in the result of a query.
The from clause is a list of the relations to be accessed in the evaluation of
the query.
The where clause is a predicate involving attributes of the relation in the
from clause.
In the case of eliminating duplicates, we insert the keyword distinct after select.
A select clause of the form select* indicates that all attributes of all relations
appearing in the form clause are selected.
Output:
JOB_TITLE MAXIMUM_SALARY
Programmer 10000
Marketing manager 15000
Finance manager 12000
account 9000
Lecturer 17000
Computer Operator 3000
Query-5: Display all jobs with minimum salary is greater than 4000.
SQL Statement:
select * from job where min_sal>4000;
Output:
JOB_ID JOB_TITLE MIN_SAL MAX_SAL
MK_MGR Marketing manager 9000 15000
FI_MGR Finance manager 8200 12000
FI_ACC account 4200 9000
LEC Lecturer 6000 17000
Output:
NAME EMP_SAL
Smith 800
Adama 1100
Query-11: Display name of customer along with its account no( both column
should be displayed as one ) whose amount is not equal to 8000 Rs.
SQL Statement:
select A_no||' '||cname from deposit where amount!=8000;
Output:
A_NO||''||CNAME
103 Adama
101 Smith
102 Snehal
105 Anita
106 Sneha
Query-12: Insert some duplicate values in deposit table and apply the concept
of Distinct and also combine two columns and display it one column using
common alias name.
SQL Statement:
select distinct A_no||' '||cname from deposit;
Output:
A_NO||''||CNAME
105 Anita
106 Sneha
102 Snehal
103 Adama
104 Aman
101 Smith
Query-13: Display the content of job details with minimum salary either 2000
or 4000.
SQL Statement:
select job_title from job where min_sal=2000 or min_sal=4000;
Output:
JOB_TITLE
Programmer