Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
1-3
Anatomy of a SQL Statement
DPS1L3
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 3
Anatomy of a SQL Statement
Objectives
DPS1L3
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 4
Anatomy of a SQL Statement
SELECT Keyword
DPS1L3
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 5
Anatomy of a SQL Statement
SELECT Statement
DPS1L3
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 6
Anatomy of a SQL Statement
Conventions
DPS1L3
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 8
Anatomy of a SQL Statement
Projection and Selection
Projection
SELECT salary
FROM employees
Selection WHERE last_name like 'Smith';
DPS1L3
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 9
Anatomy of a SQL Statement
Selecting All Columns
DPS1L3
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 10
Anatomy of a SQL Statement
Selecting All Columns
• You can also display all the columns in a table by listing them
individually.
DPS1L3
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 11
Anatomy of a SQL Statement
Projecting Specific Columns
DPS1L3
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 12
Anatomy of a SQL Statement
Using Arithmetic Operators
DPS1L3
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 13
Anatomy of a SQL Statement
Using Arithmetic Operators
DPS1L3
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 14
Anatomy of a SQL Statement
Using Arithmetic Operators
DPS1L3
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 15
Anatomy of a SQL Statement
Precedence in Arithmetic Operators
DPS1L3
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 16
Anatomy of a SQL Statement
Precedence in Arithmetic Operators
DPS1L3
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 17
Anatomy of a SQL Statement
Precedence in Arithmetic Operators
DPS1L3
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 18
Anatomy of a SQL Statement
Precedence in Arithmetic Operators
Operator Precedence Using Parentheses
SELECT last_name, salary, SELECT last_name, salary,
12*salary +100 12*(salary +100)
FROM employees; FROM employees;
DPS1L3
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 19
Anatomy of a SQL Statement
NULL Values
DPS1L3
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 20
Anatomy of a SQL Statement
NULL Values
DPS1L3
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 21
Anatomy of a SQL Statement
NULL Values
Salaries and Commissions
• If any column value in LAST_NAME JOB_ID SALARY COMMISSION_PCT
an arithmetic
King AD_PRES 24000 -
expression is null, the
result is null or Kochhar AD_VP 17000 -
an error.
DPS1L3
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 22
Anatomy of a SQL Statement
NULL Values
DPS1L3
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 23
Anatomy of a SQL Statement
Aliases
DPS1L3
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 24
Anatomy of a SQL Statement
Aliases
DPS1L3
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 25
Anatomy of a SQL Statement
Using Column Aliases
DPS1L3
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 26
Anatomy of a SQL Statement
Terminology
DPS1L3
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 27
Anatomy of a SQL Statement
Terminology
DPS1L3
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 28
Anatomy of a SQL Statement
Summary
DPS1L3
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 29
Anatomy of a SQL Statement
Summary
DPS1L3
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 30
Anatomy of a SQL Statement