[29/07/2008 21:33:45 ]
L1. Retrieving data using SELECT statement
1.Tips for writing SQL statement
a.Clauses are usually placed on separate lines.
b.In SQL Developer, SQL statements can optionally be terminated by a semicolon. Semicolons are required when you execute multiple SQL statements.
c.In SQL*Plus, you are required to end each SQL statement with a semicolon.
2.Arithmetic expressions in the SELECT statement
Example:SELECT last_name, salary, 12*(salary+100) FROM employees;
3.Column aliases
Example:SELECT last_name "Name" , salary*12 "Annual Salary" FROM employees;
4.Use of concatenation operator, literal character strings, alternative quote operator, and the DISTINCT keyword
a.Concatenation operator(||)
Example:SELECT last_name||job_id AS "Employees" FROM employees;
b.Literal Character Strings(')
Example:SELECT last_name ||' is a '||job_id AS "Employee Details" FROM employees;
c.Alternative Quote (q) Operator
Example:SELECT department_name || ' Department' || q'['s Manager Id: ]' || manager_id AS "Department and Manager" FROM departments;
d.Duplicate Rows
Example:SELECT DISTINCT department_id FROM employees;