SQL Fundamentals || Oracle SQL语言

DUAL is a public table that you can use to view results from functions and calculations.

The DUAL table is owned by the user SYS and can be accessed by all users.

It contains one column, DUMMY, and one row with the value X.

Using Single-Row Functions to Customize Output

Oracle SQL supplies a rich library of in-built functions which can be employed for various tasks. The essential capabilities of a functions can be the case conversion of strings, in-string or substring operations, mathematical computations on numeric data, and date operations on date type values. SQL Functions optionally take arguments from the user and mandatorily return a value.

  • Describe various types of functions available in SQL
  • Use character, number, and date functions in SELECT statements

字符、数字、日期函数

1、SQL Functions

Functions are a very powerful feature of SQL. They can be used to do the following:

Perform calculations on data

执行数据计算

Modify individual data items

修改单独的数据项

Manipulate output for groups of rows

操纵行组的输出

Format dates and numbers for display

格式化日期和数字进行显示

Convert column data types

转换列数据类型

SQL functions sometimes take arguments and always return a value.

SQL有时候接收参数并总是返回一个值.

2、Two Types of SQL Function:

Single-row functions

单行函数

These functions operate on single rows only and return one result per row.

单行函数只操作单个行并为每一行返回一个结果.

- Single row functions are the one who work on single row and return one output per row. For example, length and case conversion functions are single row functions.

Multiple-row functions

多行函数

- Multiple row functions work upon group of rows and return one result for the complete set of rows. They are also known as Group Functions.

3、Single-row functions单行函数

Single row functions

Single row functions can be character functions, numeric functions, date functions, and conversion functions. Note that these functions are used to manipulate data items. These functions require one or more input arguments and operate on each row, thereby returning one output value for each row. Argument can be a column, literal or an expression. Single row functions can be used in SELECT statement, WHERE and ORDER BY clause.

Single-row functions are used to manipulate data items. They accept one or more arguments and return one value for each row that is returned by the query.

(1)特点

Manipulate data items

操作数据项

Accept arguments and return one value

接收参数并返回一个值

Act on each row that is returned

每一行进行操作

Return one result per row

每一行返回一个值

Many modify the data type

单行函数可以修改数据类型

Can be nested

单行函数可以嵌套

Accept arguments that can be a column or an expression

An argument can be one of the following:

  • User-supplied constant
  • Variable value
  • Column name
  • expression

函数接收的参数可以是列名或者表达式

  • 用户提供的常量
  • 变量值
  • 列名
  • 表达式

(2)、语法

Function_name [(arg1,arg2….)]

(3)、类型

字符函数

character functions

Accept character input and can return both character and number values.

数字函数

number functions

Accept numeric input and return numeric values.

日期函数

date functions

Operate on values of the DATE data type (All date functions return a value of the DATE data type except the MONTHS_BETWEEN function, which returns a number)

所有日期函数都返回一个DATE类型的值,除了MONTHS_BETWEEN函数,它返回一个数字.

转换函数

Conversion function

Convert a value from one data type to another

通用函数

General function

      • General functions - Usually contains NULL handling functions. The functions under the category are NVL, NVL2, NULLIF, COALESCE, CASE, DECODE.

NVL:对空值做处理

NVL2:对空值做处理

NULLIF:对空值做处理

COALESCE

CASE

DECODE

General functions

The SELECT query below demonstrates the use of NVL function.

SELECT first_name, last_name, salary, NVL (commission_pct,0)
FROM employees
WHERE rownum < 5;

FIRST_NAME           LAST_NAME                     SALARY NVL(COMMISSION_PCT,0)
-------------------- ------------------------- ---------- ---------------------
Steven               King                           24000                     0
Neena                Kochhar                        17000                     0
Lex                  De Haan                        17000                     0
Alexander            Hunold                          9000                     0

SQL Fundamentals: Using Single-Row Functions to Customize Output使用单行函数自定义输出的更多相关文章

  1. Oracle SQL Lesson (3) - 使用单行函数自定义输出

    大小写转换函数LOWER('SQL Course') = sql courseUPPER('SQL Course') = SQL COURSEINITCAP('SQL Course') = Sql C ...

  2. SQL Fundamentals || Single-Row Functions || 转换函数 Conversion function

    SQL Fundamentals || Oracle SQL语言   SQL Fundamentals: Using Single-Row Functions to Customize Output使 ...

  3. SQL Fundamentals || Single-Row Functions || 字符函数 character functions

    SQL Fundamentals || Oracle SQL语言   SQL Fundamentals: Using Single-Row Functions to Customize Output使 ...

  4. SQL Fundamentals || Single-Row Functions || 通用函数 General function || (NVL,NVL2,NULLIF,DECODE,CASE,COALESCE)

    SQL Fundamentals || Oracle SQL语言 SQL Fundamentals: Using Single-Row Functions to Customize Output使用单 ...

  5. SQL Fundamentals || Single-Row Functions || 日期函数date functions

    SQL Fundamentals || Oracle SQL语言   SQL Fundamentals: Using Single-Row Functions to Customize Output使 ...

  6. SQL Fundamentals || Single-Row Functions || 数字函数number functions

    SQL Fundamentals || Oracle SQL语言 SQL Fundamentals: Using Single-Row Functions to Customize Output使用单 ...

  7. SQL Fundamentals || Oracle SQL语言

    对于SQL语言,有两个组成部分: DML(data manipulation language) 它们是SELECT.UPDATE.INSERT.DELETE,就象它的名字一样,这4条命令是用来对数据 ...

  8. 微软BI 之SSIS 系列 - Execute SQL Task 中的 Single Row 与 Full Result Set 的处理技巧

    开篇介绍 Execute SQL Task 这个控件在微软BI ETL 项目中使用的频率还是非常高的,也是大部分入门 SSIS 初学者最早接触到的几个控制流控件. 我们通常使用 Execute SQL ...

  9. SQL Fundamentals: Basic SELECT statement基本的select语句(控制操作的现实列)(FROM-SELECT)

    SQL Fundamentals || Oracle SQL语言 Capabilities of the SELECT Statement(SELECT语句的功能) Data retrieval fr ...

随机推荐

  1. Android Studio 视图解析

    AS一共同拥有三种视图.我们来分别分析每一种视图的作用. 一.Project视图.(白色字体的文件夹/文件可不关注) 图片中的链接 Gralde介绍:http://stormzhang.com/dev ...

  2. ajax简单手写了一个猜拳游戏

    使用ajax简单写一个猜拳游戏 HTML代码 <!DOCTYPE HTML> <html lang="en-US"> <head> <me ...

  3. underscore.js定义模板遇到问题:Uncaught TypeError: Cannot read property 'replace' of undefined

    代码正确缩进位置如下, extend "layout" block 'content',-> div ->'nihao' script id:"Invoice ...

  4. 顶点纹理shader

    Shader "Custom/VertDisplace" { Properties { _MainTex ("Base (RGB)", 2D) = " ...

  5. 2014 华为校招机试题(c/c++开发类)

    第一题: 1.2.3....n盏灯,同时有n个人, 第1个人将1的倍数的灯拉一下, 第2个人将2的倍数的灯拉一下, ...... 问最后有几盏灯是亮的, 初始状态下灯是灭的, 输入整数n(n<6 ...

  6. IOS设计模式第八篇之键值观察模式

    版权声明:原创作品,谢绝转载!否则将追究法律责任. 键值观察模式: 在KVO,一个对象可以要求被通知当他的某个特殊的属性被改变了.自己或者另一个对象.如果你感兴趣你可以阅读更多的信息参考: Apple ...

  7. 【基础知识】列一下一个.Net WEB程序员需要掌握的知识

    基础部分 C# 基础语法 OOP的概念,面向对象的理解 继承 封装 多态 ASP.NET MVC (Web Form 用的越来越少,如果你不熟悉,可以不看) JavaScript 基础语法 如何在HT ...

  8. Python操作MySQL数据库的三种方法

    https://blog.csdn.net/Oscer2016/article/details/70257024 1. MySQLdb 的使用 (1) 什么是MySQLdb?   MySQLdb 是用 ...

  9. css案例 - 评分效果的星星✨外衣

    纳尼?什么星星外衣?好,直接上图比较能说清楚: 仔细看会发现规律:可以根据百分比/分值动态改变高亮星星的个数. 分步骤图: 这种效果,如果遇到一分一个星,没有半星(或者有也可以,直接加一个半星的类名) ...

  10. Mobx与Redux区别

    Mobx的实现思想和Vue几乎一样,所以其优点跟Vue也差不多:通过监听数据(对象.数组)的属性变化,可以通过直接在数据上更改就能触发UI的渲染,从而做到MVVM.响应式.上手成本低.开发效率高,在数 ...