Lab 07
Lab 07
IT[244]
Lab #:07
FACULTY OF CS & IT
UNIVERSITY OF GUJRAT
Logical Operators
Operator Meaning
AND Returns TRUE if both component
conditions are TRUE
OR Returns TRUE if either component
conditions are TRUE
Name and Job title of all the employees whose Job title
is not CLERK , MANAGER or ANALYST
Rules of Precedence
Order Evaluated Operator
1 All comparison
Operators
2 NOT
3 AND
4 OR
2 SELECT statement
reads as follows:
1
Select the row that
if an employee is a
PRESIDENT and
earn more than
$1500.
Or if the employee
is a SALESMAN.
Use of Parenthesis:
To force Priority
1 SELECT statement
reads as follows:
2
Select the row that
if an employee is a
PRESIDENT or
SALESMAN and if
the employee earn
more than $1500.
ORDER BY Clause
• Sort rows with the ORDER BY clause
– ASC: ascending order , default
– DESC: descending order
• The ORDER BY clause comes last in the
SELECT statement.
– SELECT expr
FROM table
[WHERE condition(s)]
[ORDER BY {column exp} [ASC|DESC]];
ORDER BY Clause
Default
Order
Sorting in Descending Order
Sorting in
Descending
Order
Sorting by Column Alias
Column
Alias
Sorting by
Column Alias
Sorting by multiple Columns
Sorting by
multiple
Columns
Using Where clause
Using Where
clause