zoukankan      html  css  js  c++  java
  • 数据库增添

    条件查询用where

    比如:查询Score表中成绩在60到80之间的所有记录。

    select DEGREE from score where degree>60 and degree<80

    模糊查询用%

    比如查询与三相关的数据:

     where cno like '3%'   3%是已三开头   %3%是中间带3  %3是末尾带3

    排序查询 order  by desc降序  asc升序   去重查询 distinct 

    分组查询group by   联合查询union

     子查询 :

    查询Score表中的最高分的学生学号和课程号。(子查询或者排序)
    select* from score where degree in (select MAX(degree)from score)

    聚合函数: max()  min()  avg() count() sum() 

    数学函数:ceiling()  floor() round(字段名,小数位)

    abs()  pi()

    字符串函数:lower() upper() trim() replace(源字段,查找字符)

    substring(源字段,索引位置)

    转换函数 + 运算,拼接

    convert(类型,字段)

    cast(字段 as类型)

    时间日期函数:

    getdate : year(getdate())

    dateadd(增加类型,增加量,数据源,dateadd(month,7,getdate())

    datename(日期类型,数据源),datename(day,getdate())

  • 相关阅读:
    P4009 汽车加油行驶问题
    P2761 软件补丁问题
    P1251 餐巾计划问题
    P2766 最长不下降子序列问题
    P4011 孤岛营救问题
    P2765 魔术球问题
    P2770 航空路线问题
    P2762 太空飞行计划问题
    P2764 最小路径覆盖问题
    P3355 骑士共存问题
  • 原文地址:https://www.cnblogs.com/yujiamin123/p/7060374.html
Copyright © 2011-2022 走看看