- Oracle Database Vault
- REMOTE_OS_AUTHENT
- What do you do if a Control file was mistakenly deleted
- What are the characteristics of the SQL * Loader direct path load method
- Which operations should not be performedusing Shared server architecture
- Which types of Statistics can be manually collected using Enterprise Manager
- Local Naming vs Easy Connect
- Data Recovery Advisory Failures
- What is Resource Role?
- Oracle Secure Backup
- VERIFY_FUNCTION_11G
- In which situation does Datapump use external tables to load and unload data for a table?
- MTTR Advisor
- Oracle_HOME vs ORACLE_BASE
- Which directory contains the executable for the Database Configuration Assistant (DBCA)
- Quick Packaging Method
- AUDIT_TRAIL setting
- Server generated Alerts
Tuesday, 28 October 2014
OCA Questionaire - 1
Monday, 20 October 2014
Sorting
The default sort order, for the data returned by a SQL
query, is ascending. In this sort order:
·
numeric values are displayed with the lowest values first; for
example, 1 to 999
·
date values are displayed with the earliest value first; for
example, 01-JAN-92 before 01-JAN-95
·
character values are displayed in the alphabetical order; for
example, "A" first and "Z" last
·
null values are displayed last for ascending sequences and first
for descending sequences
·
you can also sort by a column that is not in the SELECT list
Here are some examples that depict sorting:
- To reverse the order in which the rows are displayed, specify the DESC keyword after the
column name in the ORDER
BY clause. This sample
code sorts the result by the most recently hired employee.
SELECT last_name, job_id, department_id, hire_date
FROM employees
ORDER BY hire_date DESC ; - You can also use a column alias in the ORDER BY clause. This sample
code sorts the data by annual salary.
SELECT employee_id, last_name, salary*12 annual
FROM employees
ORDER BY annual ; - You can sort query results by specifying the numeric position of
the column in the SELECT clause. This sample
code sorts the result by department_id, as this column is at
the third position in the SELECT clause.
SELECT last_name, job_id, department_id, hire_date
FROM employees
ORDER BY 3; - You can sort query results by more than one column. The sort limit
is the number of columns in the given table. In the ORDER BY clause, you specify the
columns and separate the column names using commas. If you want to reverse the
order of a column, specify DESC after its name, as in
this sample code.
SELECT last_name, department_id, salary
FROM employees
ORDER BY department_id, salary DESC;
Order of Precedence
The rules of precedence determine the order in which
expressions are evaluated and calculated. You can override the default order by
using parenthesis around the expressions that you want to calculate first. This
table lists the default Order of Precedence
- Arithmetic Operators
- Concatenation Operator
- Comparison Conditions
- IS [NOT] NULL, LIKE, [NOT] IN
- [NOT] BETWEEN
- Not Equal to
- NOT logical condition
- AND
- OR
Subscribe to:
Comments (Atom)