zoukankan      html  css  js  c++  java
  • sql基础知识回顾

    一:查询条件

       1:  >    <      =     >=     <=    !=   <>

     2:  and   or  

       3:  like 

       4:  in            not   in

       5:       between.......   and .....

       6:  is   null             is    not    null

       7:  any(任意一个)       all(所有

           这两个用于子查询

            例:select from student where 班级='01' and age > all (select age from student where 班级='02');   查询01班学生年龄大于02班所有的学生

                                      相当于:   select from student where 班级='01' and age > (select max(age) from student where 班级='02');

              select from student where 班级='01' and age > any (select age from student where 班级='02');   查询01班学生年龄大于02班任意学生

              相当于: select from student where 班级='01' and age > (select min(age) from student where 班级='02');

       8:  distinct    去重复

    二:排序

            order    by

             例如:select  deptno, sal, from emp order by deptno asc,sal desc;    

          其中:asc升序   desc降序

    三:分组

         group by(按什么分组)+  having(条件限制)

         例如:  select  * from  emp group by deptno having max(sal)>4000;

    四:计算函数

      1:  max     min

      2:avg(平均值) sum(合计)

      3:count(计算表中查询出来的行数)

    五:分页查询

      rownum(伪列)  返回标识行数据顺序的数字

      select * from (select ruwnum rm ,e.* from emp) where rm   between  1  and 15;

    6:decode函数

       DECODE(value,if1,then1,if2,then2,if3,then3,...,else),表示如果value等于if1时,DECODE函数的结果返回then1,...,如果不等于任何一个if值,则返回else。

      例如:select * from decode(job,'teacher',sal*1.2,'saleman',sal*1.5,sal) from emp;

     

        

      

      

       

  • 相关阅读:
    镜像源收集
    关于vue-cli3脚手架安装后回退到vue-cli2版本的问题
    window.location 对象
    常用正则表达式
    前端开发工程师面试题
    面试题1
    Echarts.js使用
    swipe.js 使用方法
    canvas基础API
    前端面试题集锦
  • 原文地址:https://www.cnblogs.com/jcfxl/p/8835487.html
Copyright © 2011-2022 走看看