Lab 1
Lab 1
2
Required installations
3
Structured Query Language
(SQL)
SQL, PL/SQL, and SQL Developer
5
Data Retrieval Command
(DRC)
Basic SELECT Statement
7
Selecting All Columns
SELECT *
FROM departments;
8
Selecting Specific Columns
* / + -
• Multiplication and division take priority over addition
and subtraction.
• Operators from the same priority are evaluated from
left to right.
• Parentheses are used to enforce prioritized
evaluation and to clarify statements.
11
Operator Precedence
12
Using Parentheses
14
Null Values
in Arithmetic Expressions
15
Defining a Column Alias
A column alias:
• Renames a column heading
• Is useful with calculations
• Immediately follows the column name
• The optional AS keyword may be used between the
column name and alias
• Requires double quotation marks if it contains spaces
or special characters (such as # or $), or is case
sensitive
16
Using Column Aliases
SELECT last_name AS name, commission_pct comm
FROM employees;
17
Duplicate Rows
SELECT department_id
FROM employees;
18
Eliminating Duplicate Rows
Eliminate duplicate rows by using the DISTINCT keyword
in the SELECT clause.
SELECT DISTINCT department_id
FROM employees;
19
Eliminating Duplicate Rows
20
Restricting Data
Limiting the Rows Selected
22
Using the WHERE Clause
= Equal , < Less than , > Greater than , <> Not equal
23
Character Strings and Dates
24
Using Comparison Conditions
25
Other Comparison Conditions
Operator Meaning
26
The BETWEEN Condition
28
The LIKE Condition
SELECT first_name
FROM employees
WHERE first_name LIKE 'S%';
29
Using the LIKE Condition
30
The NULL Conditions
31
Logical Conditions
Operator Meaning
32
Using the AND Operator
33
Using the OR Operator
34
Using the NOT Operator
35
Sorting Data
The ORDER BY Clause
37
Sorting in Descending Order
38
Sorting by Multiple Columns
39
Thank You