1、concat
CONCAT(字串1, 字串2, 字串3, ...): 将字串1、字串2、字串3,等字串连在一起。
例如:
Geography 表格
region_name     store_name
East        Boston
East           New York
West         Los Angeles
West         San Diego

例子1:

MySQL/Oracle:
SELECT CONCAT(region_name,store_name) FROM Geography
WHERE store_name = 'Boston';

结果:

'EastBoston'
 

 
2、oracel中to_date函数的用法 ,用来查询时间段。
sql="select * from managedate where  aaa_date>="&2005-11-1&"and aaa_date<="&2005-11-20&"
 
to_date('2011-8-22 09:00:00','yyyy-mm-dd hh24:mi:ss')
 

3、trunc函数的用法
--Oracle trunc()函数的用法
/**************日期********************/
1.select trunc(sysdate) from dual --2013-01-06 今天的日期为2013-01-06
2.select trunc(sysdate, 'mm') from dual --2013-01-01 返回当月第一天.
3.select trunc(sysdate,'yy') from dual --2013-01-01 返回当年第一天
4.select trunc(sysdate,'dd') from dual --2013-01-06 返回当前年月日
5.select trunc(sysdate,'yyyy') from dual --2013-01-01 返回当年第一天
6.select trunc(sysdate,'d') from dual --2013-01-06 (星期天)返回当前星期的第一天
7.select trunc(sysdate, 'hh') from dual --2013-01-06 17:00:00 当前时间为17:35
8.select trunc(sysdate, 'mi') from dual --2013-01-06 17:35:00 TRUNC()函数没有秒的精确
/***************数字********************/
/*
TRUNC(number,num_digits)
Number 需要截尾取整的数字。
Num_digits 用于指定取整精度的数字。Num_digits 的默认值为 0。
TRUNC()函数截取时不进行四舍五入
*/
9.select trunc(123.458) from dual --123
10.select trunc(123.458,0) from dual --123
11.select trunc(123.458,1) from dual --123.4
12.select trunc(123.458,-1) from dual --120
13.select trunc(123.458,-4) from dual --0
14.select trunc(123.458,4) from dual --123.458
15.select trunc(123) from dual --123
16.select trunc(123,1) from dual --123
17.select trunc(123,-1) from dual --120
 

4、

在Oracle/PLSQL中, sign 函数返回一个数字的正负标志.

语法如下:sign( number )

number 要测试标志的数字.

If number < 0, then sign returns -1.

If number = 0, then sign returns 0.

If number > 0, then sign returns 1
 

5、查询sql字段长度
length()函数。
 
 

 
6、decode(条件,值1,翻译值1,值2,翻译值2,...值n,翻译值n,缺省值)的理解如下:

if (条件==值1)

then    

return(翻译值1)

elsif (条件==值2)

then    

return(翻译值2)    

......

elsif (条件==值n)

then    

return(翻译值n)

else    

return(缺省值)

end if

 
注:其中缺省值可以是你要选择的column name 本身,也可以是你想定义的其他值,比如Other等;
 

5、Lpad()函数
lpad函数将左边的字符串填充一些特定的字符
1.语法格式如下:  
     lpad(string,n,[pad_string])
参数说明:
     string:    字符串或者列名。
     n:         字符串总长度。如果这个值比原字符串的长度还要短,lpad函数将会把字符串截取成从左到右的n个字符;
     pad_string:要填充的字符串,默认为填充空格。
2.例子
select lpad('tech',7) from dual;
--将返回'   tech'
select lpad('tech', 2) from dual;
--将返回'te'
select lpad('tech', 8, '0') from dual;
--将返回'0000tech'
select empno,lpad(ename,7) as ename from emp;

--将返回:

 
EMPNO ENAME

sql语句中特殊函数的用法的更多相关文章

  1. sql语句中charindex的用法 可用于截取字符串

    使用CHARINDEX和PATINDEX函数来搜索文字列和字符串.这两个函数是如何运转的,解释他们的区别.同时提供一些例子,通过这些例子,你可以可以考虑使用这两个函数来解决很多不同的字符搜索的问题. ...

  2. SQL语句中output的用法

    在SQL语句中,output可以作为返回值来使用, 1.我们先看这个存储过程 代码: 1 set ANSI_NULLS ON  2 set QUOTED_IDENTIFIER ON  3 go  4 ...

  3. [SQL]sql语句中charindex的用法

    假如你写过很多程序,你可能偶尔会碰到要确定字符或字符窜串否包含在一段文字中,在这篇文章中,我将讨论使用CHARINDEX和PATINDEX函数来搜索文字列和字符串.我将告诉你这两个函数是如何运转的,解 ...

  4. (转)sql语句中charindex的用法

    假如你写过很多程序,你可能偶尔会碰到要确定字符或字符窜串否包含在一段文字中,在这篇文章中,我将讨论使用CHARINDEX和PATINDEX函数来搜索文字列和字符串.我将告诉你这两个函数是如何运转的,解 ...

  5. sql语句中charindex的用法

    假如你写过很多程序,你可能偶尔会碰到要确定字符或字符窜串否包含在一段文字中,在这篇文章中,我将讨论使用CHARINDEX和PATINDEX函数来 搜索文字列和字符串.我将告诉你这两个函数是如何运转的, ...

  6. Sql语句中Like嵌套用法

    一般的Like用法: SELECT U_NAME FROM T_USER WHERE U_NAME LIKE '%A%' 但是,我此次like关键字后面的对应值是一个变量,需要用select语句来实现 ...

  7. sql语句中 limi的用法

    SELECT * FROM table LIMIT [offset,] rows | rows OFFSET offset 使用查询语句时需要返回前几条或者中间的某几行数据时可以用到limit 例如 ...

  8. sql语句中的join用法(可视化解释)

    一.innerjoin innerjoin总结来说就是 ,如A知道通往B如何走:B知道通往C如何走:但是A不知道通往C如何走,但是A可以通过B获得去往C的通往方式.. 首先,假设有A,B两张表,结构及 ...

  9. SQL语句中的output用法

    private void button2_Click(object sender, RoutedEventArgs e) { using (SqlConnection conn = new SqlCo ...

随机推荐

  1. IOS学习笔记07---C语言函数-printf函数

    IOS学习笔记07---C语言函数-printf函数 0 7.C语言5-printf函数 ------------------------- ----------------------------- ...

  2. Unity插件之NGUI学习(1)—— 环境搭建

    Unity官网http://unity3d.com/unity/download下载最新版本号4.5.4 在圣典论坛上找到破解补丁(Windows)版本号tid=18741&fid=8&quo ...

  3. openstack之horizon源码分析之二

    一.概述: django基础入手: django新建project:#django-admin startproject mysite 生成如下目录: mysite ├── manage.py └── ...

  4. javaScript 工作必知(十) call apply bind

    call  每个func 都会继承call apply等方法. function print(mesage) { console.log(mesage); return mesage; } print ...

  5. Fast InvSqrt()(平方根倒数速算法)

    浮点数的平方根倒数常用于计算正规化矢量.3D图形程序需要使用正规化矢量来实现光照和投影效果,因此每秒都需要做上百万次平方根倒数运算,而在处理坐标转换与光源的专用硬件设备出现前,这些计算都由软件完成,计 ...

  6. Python核心编程读笔 13:执行环境

    第14章  执行环境 一.可调用对象 python有四种可调用对象:函数.方法.类.一些类的实例 1 函数 (1)内建函数(BIF) BIF是用c/c++写的,编译后放入python解释器,然后把它们 ...

  7. Rectangles

    Given two rectangles and the coordinates of two points on the diagonals of each rectangle,you have t ...

  8. leetcode Letter Combinations of a Phone Number python

    class Solution(object): def letterCombinations(self, digits): """ :type digits: str : ...

  9. C#时间日期操作

     一.C# 日期格式 DateTime dt = DateTime.Now; dt.ToString();//2005-11-5 13:21:25 dt.ToFileTime().ToString() ...

  10. php中date函数获取当前时间的时区误差解决办法

    例:echo date('Y-m-d H:i:s', time()); 输出时间:2008-10-12 02:32:17 但实际时间是:2008-10-12 10:32:17时间误差8个小时 PHP手 ...