SQL----函数
在看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
轉載于:https://blog.51cto.com/ehealth/1718733
總結
- 上一篇: System Center Techni
- 下一篇: Virtual Network (1)