首页 > 数据库技术 > 详细

SQL----函数

时间:2015-12-02 12:42:39      阅读:261      评论:0      收藏:0      [点我收藏+]

在看script的时候,经常会发现一些看不懂的地方。搜索了一下,发现sql还有很多的函数,这是以前不了解的。在这里做一个练习跟总结


--------|length()

        返回字符串的长度

    select  length(alliance_id)  from  application;


--------|substr(string,start,count)

取子字符串,从start开始,取出count个字符

    select substr(application_receipt_date,2,3)from application;


-------|replace(string,s1,s2)

string 希望被替换掉的字符或者变量

s1:被替换的字符

s2:要替换的字符

   select replace(application_receipt_date,‘JUN‘,‘otc‘)from application;


--------|add_months()

增加或者删减月份


-------|last_day

返回日期的最后一天


-------|months_between(date2,date1)

返回date2-date1之间的月份


-------|to_char , TO_MULTI_BYTE , TO_NUMBER

select to_char(application_receipt_date,‘mm.dd‘)from application;

------|sysdate

返回系统时间


 ------|LEAST , min() ,max()

返回一组表达式中最 大/小 的值


-------|UID

返回当前用户的唯一整数


------|AVG(distinct|all)

all 对于所有的值求平均值

distinct 只对不同的值求平均值


------|group by 

主要对于一组数做统计

select application_id,count(*) from application group by application_id;

表示从这个表中选取application 并且统计出现的总数。


------|having

对于分组统计再加上限制条件,类似where

------|order by.... desc

对于查询结果进行排序。

desc属于降序排序


更多函数可参考:

    http://www.cnblogs.com/zhangronghua/archive/2007/08/20/862812.html

SQL----函数

原文:http://ehealth.blog.51cto.com/10942284/1718733

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!