Wednesday, November 27, 2013

Arithmetic Expressions


Arithmetic expressions can be used with SQL statements.

Operator
Description
+
Add
-
Subtract
*
Multiply
/
Divide

Using arithmetic expression in queries
Example
SELECT first_name, salary, salary + 500 FROM   employees;
As result from above query 500 will be added all employees salary and will be shown separately.
First_name
Salary
Salary +500
Kery
400
900
Edy
340
840



Tuesday, November 26, 2013

Basic SELECT Statement

SELECT *|{[DISTINCT] column|expression [alias],...}
FROM    table;

SELECT identifies the columns to be displayed
•FROM identifies the table containing those columns

To SELECT all columns from a particular table, the following command is used.


SELECT * FROM   departments;

To SELECT specific columns, column names should be mentioned as below.


SELECT department_id, location_id FROM   departments;

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.
•Indents are used to enhance readability.
•In iSQL*Plus, SQL statements can optionally be terminated by a semicolon (;).
Semicolons are required if you execute multiple SQL statements.
•In SQL*plus, you are required to end each SQL statement with a semicolon (;).



Reference : Oracle docs