常用的函数

--数学函数

select 列 ,sqrt(列) from score --开平方,平方根

select 数列, ceiling(数列) from car -- 取大于当前小数的最小整数

select 数列, floor(数列) from car -- 取小于当前小数的最大整数

select 数列, round(数列,-1) from car -- 四舍五入,保留几位,-1保留10位

select ABS(-2) -- 取绝对值

select RAND()*100 -- 生成随机数,默认是生成0-1之间的数

--字符串函数

select LOWER(‘Welcome‘) --转小写 select UPPER(‘welcome‘) --转大写 select LTRIM(‘   hello‘)--压缩左边的空格 select RTRIM(‘hello   ‘)--压缩右边的空格 select * from News select left(title,5) from News -- 从左侧截取字符串,截5个字符 select right(title,5) from News --从右侧截取字符串,截5个字符 select substring(title,3,5) from News--从某位置截取字符串,截取长度为n select reverse(title) from News -- 翻转字符串 select replace(title,‘中国‘,‘美国‘) from News --替换字符串 select STUFF(title,4,3,‘中国‘) from News--替换指定位置的字符串 从第四个位置换了3三个字符 select LEN(‘ hello‘) -- 返回字符串的长度

--日期时间函数

select * from student select year(sbirthday) from student -- 取日期时间中的年份 select month(sbirthday) from student -- 取日期时间中的月份 select day(sbirthday) from student -- 取日期时间中的天 select GETDATE() --获取当前系统的时间 select datepart(yy,sbirthday) from student--取日期时间的一部分

--类型转换 select len(cast(0.2 as varchar(50)))--cast(源数据 as 目标类型)--将0.2转换为字符串 len代表字符串的长度

时间: 2025-01-18 11:46:08

常用的函数的相关文章

sql常用格式化函数及字符串函数

一.常用格式化函数 1.日期转字符串 select to_char(current_timestamp, 'YYYY-MM-DD HH24:MI:SS') //2017-09-18 22:41:50 YYYY:年(4和更多位) MM:月份号(01-12) DD:一个月里的日(01-31) HH24:一天的小时数(00-23) MI:分钟(00-59) SS:秒(00-59) 2.字符串转日期 select to_date('2017-09-18','YYYY-MM-DD') //2017-09-

在PHP编程中常用的函数

<?php//===============================时间日期===============================//y返回年最后两位,Y年四位数,m月份数字,M月份英文.d月份几号数字,D星期几英文$date=date("Y-m-d");$date=date("Y-m-d H:i:s");//带时分秒 //include,include_once.require,require_once//require("file

嵌入式之---常用模板函数(用法说明函数、参数解析函数)

主要内容:嵌入式常用模板函数(用法说明函数.参数解析函数) /*显示参数列表*/ void usage() {     printf("usage: server [-p:x] [-i:IP] [-o]\n\n");     printf("       -p:x      Port number to listen on\n");     printf("       -i:str    Interface to listen on\n");

SP常用的函数

ASP常用的函数,希望能用的着. <% dim db db="dbms.mdb" '****************************************************************** '执行sql语句,不返回值,sql语句最好是如下: 'update 表名 set 字段名=value,字段名=value where 字段名=value 'delete from 表名 where 字段名=value 'insert into 表名 (字段名,字段名

MySQL常用字符函数简介

<html> <body> <h1>MySQL常用字符函数简介</h1> <table>     <tr>         <td>CONCAT(S1,S2...Sn)</td>         <td>连接S1,S2...Sn为一个字符串</td>     </tr> </table> <p style="background-color:yel

Oracl常用e函数整理

最近学Oracle数据库,常常遇到Oracle数据库函数问题,经过默默地琢磨处理,总结了一些Oracle数据库常用函数. ------------------------------------ ---->oracle常用基本函数(附例子)<---- ------------------------------------ ------------------------ ---->常用的字符函数<---- ------------------------ --initap()单词

linux常用C函数目录

字符测试篇 isalnum isalpha isascii iscntrl isdigit isgraphis islower isprint isspace ispunct isupper isxdigit 字符串转换篇 atof atoi atol gcvt strtod strtol strtoul toascii tolower toupper 内存控制篇 calloc free getpagesize malloc mmap munmap 日期时间篇 asctime ctime get

常用hash函数对比分析(一)

主要目标:寻找一个hash函数,高效的支持64位整数运算,使得在速度.空间等效率相对其它函数函数较高,以及内部运算时32位整数运算. 测试了"RSHash","JSHash","PJWHash","ELFHash","BKDRHash","SDBMHash","DJBHash","DEKHash","BPHash","

Oracle 常用系统函数

2  字符函数 1.    replace( 字符串1,字符串2,字符串3) replace( char, search_string, replace_string) 功能:在"字符串1"中搜索"字符串2",并将其替换为"字符串3". 例如下面的命令是将所有员工名字中出现的"A"替换为"中国". SQL>selectreplace(ename, 'A', '中国') from scott.emp;

C# 常用日期函数

我想知道取的时期是几月.几日,然后做一些统计,上网找了一些方法. --DateTime 数字型 System.DateTime currentTime=new System.DateTime(); 1.1 取当前年月日时分秒 currentTime=System.DateTime.Now; 1.2 取当前年 int 年=currentTime.Year; 1.3 取当前月 int 月=currentTime.Month; 1.4 取当前日 int 日=currentTime.Day; 1.5 取