网站首页  汉语字词  英语词汇  考试资料  写作素材  旧版资料

请输入您要查询的考试资料:

 

标题 必须会的sql语句(七) 字符串函数、时间函数
内容
    字符串函数
    1.大小写转换
    --upper 转化成大写
    --lower 转换成小写
    select upper('asar')
    2.长度
    --len 字数
    --datalength 字节数
    3.去除前后空格
    --rtrim 去除右边空格
    --ltrim 去除左边空格
    4.字符串截取
    --left('串',15) 从左侧开始 截取15个字节
    --right('串',15) 从右侧开始 截取15个字节
    --substring('串',5,5) 从左侧第5个字节开始,截取5个字节
    5.字符串替换
    --replace('你们','你','我') 把你们 替换成 我们
    时间函数
    1.获取当前日期
    --getdate()
    2.100天以后
    --dateadd(day,100,getdate())
    3.时间差函数
    --dateiff(year,'1990/10/11',getdate())
    4.查询年月日
    --year(时间) 获取年
    --month(时间) 获取月
    --day(时间) 获取日
    ————————————————
    --计算出每个年份出生的人数
    select year(birthday),count(*)
    from 表
    group by year([birthday])
    5.获取日期的年、月、日、时、分、秒
    datepart(year,日期)
    datepart(month,日期)
    datepart(day,日期)
    datepart(hour,日期)
    datepart(minute,日期)
    datepart(second,日期)
随便看

 

在线学习网考试资料包含高考、自考、专升本考试、人事考试、公务员考试、大学生村官考试、特岗教师招聘考试、事业单位招聘考试、企业人才招聘、银行招聘、教师招聘、农村信用社招聘、各类资格证书考试等各类考试资料。

 

Copyright © 2002-2024 cuapp.net All Rights Reserved
更新时间:2025/5/16 18:52:58