zoukankan      html  css  js  c++  java
  • SQL 常用语句摘录

    1、取不重复的工资信息

        Select distinct salary from table1   

        注:distinct是对整个结果集进行重复处理的,而不是针对每一个列。 如distinct后有多列,则是针对多列,不是单列  例:select  distinct salary,sName from table1

    2、在表中新加一列

        alter table table1 add colum varchar(20) null;

    3、Union

       select name,password from table1 union select name,password from table2

       注:union前后两个select后的选项需要保持一致,而union也会将重复数据行去掉保留一条,如果想他全部显示出来则在union后面加上all

            select name,password from table1 union all select name,password from table2

    4、函数

        ABS() 求绝对值

        celling() 舍入到最大整数

        round() 四舍五入

        floor() 舍入到最小整数

        len() 计算字符串长度

        lower()、upper() 转小写 大写

        ltrim()   去掉左边字符串空格

        rtrim()   去掉右边字符串空格    如果需要去掉左右两边则:ltrim(rtrim('  b   ' ))

        substing(str,start_position ,length) 截取字符串。string被截字符串,start_position 起始位置,length长度

        getdate()  取得当前日期时间

        dateadd(datepart,number,date) 计算增加以后的日期。date为待计算的日期,datepart为计量单位,如day,month等,number为增量

             如:select dateadd(day,3,getdate())

        dateiff(datepart,startdate,enddate)计算两个日期间的差额   ,datepart为计量单位,startdate起始时间,endstart结束时间

  • 相关阅读:
    Can you answer these queries? (线段树
    小a的排列(牛客)
    Count the Colors 线段树
    Mayor's posters (离散化线段树+对lazy的理解)
    出题人的手环(求逆序对数)
    [BZOJ2251/BJWC2010]外星联络
    [ZJOI2007]报表统计
    [JLOI2016]圆的异或并
    [ZJOI2008]无序运动Movement
    [NOI2011]阿狸的打字机
  • 原文地址:https://www.cnblogs.com/colyn/p/2361933.html
Copyright © 2011-2022 走看看