Introduction to the actual application solution of Oracle SELECT

Source: Internet
Author: User

If you are performing Oracle SELECT operations in Oracle query statements, you may not be able to understand Oracle SELECT operations in Oracle query statements, you can use the following articles to learn about its practical application and functions. The following is a detailed introduction of the article.

SELECT field name 1, field name 2 ,...... FROM table name 1, [Table name 2,...] WHERE condition;

Field names can be imported into functions.

For example, COUNT (*), MIN (field name), MAX (field name), AVG (field name), DISTINCT (field name ),

 
 
  1. TO_CHAR (DATE Field name, 'yyyy-MM-DD HH24: MI: ss ')

NVL (EXPR1, EXPR2) Function

Explanation:

 
 
  1. IF EXPR1=NULL 
  2. RETURN EXPR2  
  3. ELSE  
  4. RETURN EXPR1  

DECODE (AA, V1, R1, V2, R2....) Function

Explanation:

 
 
  1. IF AA=V1 THEN RETURN R1  
  2. IF AA=V2 THEN RETURN R2  
  3. ELSE  
  4. RETURN NULL  

LPAD (char1, n, char2) Functions

Explanation:

Character char1 is displayed based on the specified number of digits n. The reserved number of digits is replaced by the reserved number on the left using the char2 string.

Arithmetic Operations can be performed between Field Names

Example: (field name 1 * field name 1)/3

The query statement can be nested.

Example: SELECT ...... FROM

(Oracle SELECT ...... FROM table name 1, [Table name 2,...] WHERE condition) WHERE condition 2;

The results of two query statements can be set.

Example: UNION (remove duplicate records), union all (do not remove duplicate records), difference set MINUS, intersection INTERSECT

Group Query

SELECT field name 1, field name 2 ,...... FROM table name 1, [Table name 2,...] Group by field name 1

[HAVING condition];

Query connections between two or more tables

SELECT field name 1, field name 2 ,...... FROM table name 1, [Table name 2,...] WHERE

Table Name 1. Field name = table name 2. Field name [AND…] ;

Oracle SELECT field name 1, field name 2 ,...... FROM table name 1, [Table name 2,...] WHERE

Table Name 1. Field name = table name 2. Field name (+) [AND…] ;

The position of a field with a (+) number is automatically null.

Sort the query result set. The default sorting is ASC in ascending order and DESC in descending order.

Oracle SELECT field name 1, field name 2 ,...... FROM table name 1, [Table name 2,...]

Order by field name 1, field name 2 DESC;

Fuzzy string comparison

INSTR (field name, 'string')> 0

Field name LIKE 'string % '[' % string % ']

Each table has an implicit field ROWID, which indicates the uniqueness of the record.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.