Lession 01
Lession 01
SQL STATEMENTS
OBJECTIVES
After completing this lesson, you should be able to
do the following:
Execute a basic SELECT statement
Using Arithmetic Expressions
NULL Value Definition
Column Alias
Concatenation Operator
Distinct Keyword
SQL STATEMENTS
SQL statements are not case sensitive.
SQL statements can be on one or more lines.
Keywords cannot be abbreviated or split across lines.
Clauses are usually placed on separate lines.
ARITHMETIC EXPRESSIONS
Create expressions with number and date data by using arithmetic
operators.
Operator
Description
Add
Subtract
Multiply
Divide
OPERATOR PRECEDENCE
* / +
OPERATOR PRECEDENCE
SELECT last_name, salary, 12*salary+100
FROM
employees;
USING PARENTHESES
SELECT last_name, salary, 12*(salary+100)
FROM employees;
NULL VALUES
IN ARITHMETIC EXPRESSIONS
Arithmetic expressions containing a null value evaluate to null.
SELECT last_name, 12*salary*commission_pct
FROM
employees;
CONCATENATION OPERATOR
A concatenation operator:
Concatenates columns or character strings to other columns
Is represented by two vertical bars (||)
Creates a resultant column that is a character expression
last_name||job_id AS "Employees"
employees;
DUPLICATE ROWS
The default display of queries is all rows, including duplicate rows.
SELECT
SELECT
FROM
FROM
department_id
department_id
employees;
employees;
DESC
DESC tablename
tablename
SUMMARY
In this lesson, you should have learned how to: