You are on page 1of 25

SQL

Structured Query Language

SHAHINZA MANZOOR
Lab .Engineer
shahinzam0s23@gmail.com
Use Of where CLAUSE

The where clause can compare value in column, arithmetic expression or function.

Syntax
Where restrict the query to the row that meet the condition
Condition is compared the column name, arithmetic
expression
Example:
SELECT column name
FROM table name
WHERE condition
Example
Comparison Condition
Comparison Condition
Other comparison operator
Use of BETWEEN
Use of IN
Example
Use of NULL

NVL(comm,0)
Tasks:

 Display salary of SMITH;


 Display employee name whose job is manager;
 Show employee name whose salary is between 800 to 1250;
 Show employee name whose job is clerk;
 Show employees name which are working in department number 20;
 show employee name which are working as a clerk and analyst
(Use IN Operator)
 Show employee name and salary whose hire date is 23-JAN-82 and 19-APR-87
(Use IN Operator)
String case Conversion Function

 Upper (‘ali’)=ALI
 Lower(‘ALI’)=ali
 Initcap (‘ali’)=Ali
Logical condition
Use Of AND
Use Of AND Operator
Use Of OR Operator
Use of OR
Use Of Not Operator
Us Of NOT IN Operator
Sorting By Multiple Column

Example:
Sorting In DEC Order
Sorting By Column Alias
Tasks:

 Display name of employee who don’t have manager


 Display name of employee who must have manager
 Display the name of employee whose job is manager and department no is 20;
 Display name of employee who have more than 30 year of working and don’t
have manager;
 Display the name of Employee his salary his Commission and monthly total
salary which is salary + commission
Summary
Solution

 Select ename form emp where round((sysdate-hiredate)/365) AND MGR is


NULL;
 select ename ,sal ,comm ,sal +NVL(comm,0) from emp;

You might also like