MySQL入门篇-MySQL高级窗口函数简介

news2024/11/26 3:51:52

备注:测试数据库版本为MySQL 8.0

这个blog我们来聊聊MySQL高级窗口函数
窗口函数在复杂查询以及数据仓库中应用得比较频繁
与sql打交道比较多的技术人员都需要掌握

如需要scott用户下建表及录入数据语句,可参考:
scott建表及录入数据sql脚本

 

分析函数有3个基本组成部分:
1.分区子句
2.排序子句
3.开窗子句

function1 (argument1,argument2,..argumentN)
over  w
window w as ([partition-by-clause] [order-by-clause] [windowing-clause])

窗口说明子句的语法:
默认的窗口子句是rows between unbounded preceding and current row。如果你没有显示声明窗口,就将会使用默认窗口。
并不是所有的分析函数都支持开窗子句

[rows | range] between <start expr> and [end expr]

whereas
<start expr> is [unbounded preceding | current row | n preceding | n following]
<end expr> is [unbounded following | current row | n preceding | n following]

row_number、rank、dense_rank 

row_number语法:

row_number() over w
window w as (partition-clause order-by-clause)

row_number不支持开窗子句
rank、dense_rank语法同row_number语法

现在需要对分不同部门来看部门内的工资排名,且从大到小排列:

-- 可以看到deptno为30的员工工资有重复的,重复的工资为1250
-- row_number()  不关注重复的,直接排名,1-2-3-4-5-6
-- rank()        重复排名,会跳过,1-2-3-4-4-6
-- dense_rank()  重复排名,不跳过,1-2-3-4-4-5
select a.empno,
       a.ename,
       a.deptno,
       a.sal,
       row_number() over w as 'num',
       rank() over w as 'rank',
       dense_rank() over w  as 'dense_rank'
  from emp a
  window w as (partition by a.deptno order by a.sal desc)
;
mysql> select a.empno,
    ->        a.ename,
    ->        a.deptno,
    ->        a.sal,
    ->        row_number() over w as 'num',
    ->        rank() over w as 'rank',
    ->        dense_rank() over w  as 'dense_rank'
    ->   from emp a
    ->   window w as (partition by a.deptno order by a.sal desc)
    -> ;
+-------+--------+--------+---------+-----+------+------------+
| empno | ename  | deptno | sal     | num | rank | dense_rank |
+-------+--------+--------+---------+-----+------+------------+
|  7839 | KING   |     10 | 5000.00 |   1 |    1 |          1 |
|  7782 | CLARK  |     10 | 2450.00 |   2 |    2 |          2 |
|  7934 | MILLER |     10 | 1300.00 |   3 |    3 |          3 |
|  7788 | SCOTT  |     20 | 3000.00 |   1 |    1 |          1 |
|  7902 | FORD   |     20 | 3000.00 |   2 |    1 |          1 |
|  7566 | JONES  |     20 | 2975.00 |   3 |    3 |          2 |
|  7876 | ADAMS  |     20 | 1100.00 |   4 |    4 |          3 |
|  7369 | SMITH  |     20 |  800.00 |   5 |    5 |          4 |
|  7698 | BLAKE  |     30 | 2850.00 |   1 |    1 |          1 |
|  7499 | ALLEN  |     30 | 1600.00 |   2 |    2 |          2 |
|  7844 | TURNER |     30 | 1500.00 |   3 |    3 |          3 |
|  7521 | WARD   |     30 | 1250.00 |   4 |    4 |          4 |
|  7654 | MARTIN |     30 | 1250.00 |   5 |    4 |          4 |
|  7900 | JAMES  |     30 |  950.00 |   6 |    6 |          5 |
+-------+--------+--------+---------+-----+------+------------+
14 rows in set (0.01 sec)

lag、lead

lag语法:

lag (expression, offset, default) over w
window w as  (partition-clause order-by-clause)

lag不支持开窗子句
lead同lag语法

-- 根据分组,取值上n条和下n条   如果是第一条或最后一条,就给个默认值
SELECT a.empno,
       a.deptno,
       a.hiredate,
       a.sal,
       lag(sal, 1, 0) over w as 'pre_sal',
       lead(sal, 1, 0) over w as 'next_sal',
       lag(sal, 2, 0) over w  as 'pre2_sal',
       lead(sal, 2, 0) over w as 'next_2sal'
  FROM emp a
  window w  as (PARTITION BY a.deptno ORDER BY hiredate ASC)
;
mysql> SELECT a.empno,
    ->        a.deptno,
    ->        a.hiredate,
    ->        a.sal,
    ->        lag(sal, 1, 0) over w as 'pre_sal',
    ->        lead(sal, 1, 0) over w as 'next_sal',
    ->        lag(sal, 2, 0) over w  as 'pre2_sal',
    ->        lead(sal, 2, 0) over w as 'next_2sal'
    ->   FROM emp a
    ->   window w  as (PARTITION BY a.deptno ORDER BY hiredate ASC)
    -> ;
+-------+--------+------------+---------+---------+----------+----------+-----------+
| empno | deptno | hiredate   | sal     | pre_sal | next_sal | pre2_sal | next_2sal |
+-------+--------+------------+---------+---------+----------+----------+-----------+
|  7782 |     10 | 1981-06-09 | 2450.00 |    0.00 |  5000.00 |     0.00 |   1300.00 |
|  7839 |     10 | 1981-11-17 | 5000.00 | 2450.00 |  1300.00 |     0.00 |      0.00 |
|  7934 |     10 | 1982-01-23 | 1300.00 | 5000.00 |     0.00 |  2450.00 |      0.00 |
|  7369 |     20 | 1980-12-17 |  800.00 |    0.00 |  2975.00 |     0.00 |   3000.00 |
|  7566 |     20 | 1981-04-02 | 2975.00 |  800.00 |  3000.00 |     0.00 |   3000.00 |
|  7902 |     20 | 1981-12-03 | 3000.00 | 2975.00 |  3000.00 |   800.00 |   1100.00 |
|  7788 |     20 | 1987-06-13 | 3000.00 | 3000.00 |  1100.00 |  2975.00 |      0.00 |
|  7876 |     20 | 1987-06-13 | 1100.00 | 3000.00 |     0.00 |  3000.00 |      0.00 |
|  7499 |     30 | 1981-02-20 | 1600.00 |    0.00 |  1250.00 |     0.00 |   2850.00 |
|  7521 |     30 | 1981-02-22 | 1250.00 | 1600.00 |  2850.00 |     0.00 |   1500.00 |
|  7698 |     30 | 1981-05-01 | 2850.00 | 1250.00 |  1500.00 |  1600.00 |   1250.00 |
|  7844 |     30 | 1981-09-08 | 1500.00 | 2850.00 |  1250.00 |  1250.00 |    950.00 |
|  7654 |     30 | 1981-09-28 | 1250.00 | 1500.00 |   950.00 |  2850.00 |      0.00 |
|  7900 |     30 | 1981-12-03 |  950.00 | 1250.00 |     0.00 |  1500.00 |      0.00 |
+-------+--------+------------+---------+---------+----------+----------+-----------+
14 rows in set (0.00 sec)

-- 没有比自己小我的我们设为AAA,没有比自己大的,我们设置为ZZZ
select deptno,
       ename,
       lag(ename, 1, 'AAA') over w as 'lower_name',
       lead(ename, 1, 'ZZZ') over w as 'higher_name'
  from emp
window w as(PARTITION BY deptno ORDER BY ename)
;

-- 部门重复的话值输出第一行的部门编号  
select (case when deptno= lag(deptno,1)over w then null else deptno end) as 'deptno',
        ename,
       lag(ename, 1, 'AAA') over w  as 'lower_name',
       lead(ename, 1, 'ZZZ') over w as 'higher_name'
  from emp
window w  as (PARTITION BY deptno ORDER BY ename)
;
mysql> -- 没有比自己小我的我们设为AAA,没有比自己大的,我们设置为ZZZ
mysql> select deptno,
    ->        ename,
    ->        lag(ename, 1, 'AAA') over w as 'lower_name',
    ->        lead(ename, 1, 'ZZZ') over w as 'higher_name'
    ->   from emp
    -> window w as(PARTITION BY deptno ORDER BY ename)
    -> ;
+--------+--------+------------+-------------+
| deptno | ename  | lower_name | higher_name |
+--------+--------+------------+-------------+
|     10 | CLARK  | AAA        | KING        |
|     10 | KING   | CLARK      | MILLER      |
|     10 | MILLER | KING       | ZZZ         |
|     20 | ADAMS  | AAA        | FORD        |
|     20 | FORD   | ADAMS      | JONES       |
|     20 | JONES  | FORD       | SCOTT       |
|     20 | SCOTT  | JONES      | SMITH       |
|     20 | SMITH  | SCOTT      | ZZZ         |
|     30 | ALLEN  | AAA        | BLAKE       |
|     30 | BLAKE  | ALLEN      | JAMES       |
|     30 | JAMES  | BLAKE      | MARTIN      |
|     30 | MARTIN | JAMES      | TURNER      |
|     30 | TURNER | MARTIN     | WARD        |
|     30 | WARD   | TURNER     | ZZZ         |
+--------+--------+------------+-------------+
14 rows in set (0.00 sec)

mysql>
mysql> -- 部门重复的话值输出第一行的部门编号
mysql> select (case when deptno= lag(deptno,1)over w then null else deptno end) as 'deptno',
    ->         ename,
    ->        lag(ename, 1, 'AAA') over w  as 'lower_name',
    ->        lead(ename, 1, 'ZZZ') over w as 'higher_name'
    ->   from emp
    -> window w  as (PARTITION BY deptno ORDER BY ename)
    -> ;
+--------+--------+------------+-------------+
| deptno | ename  | lower_name | higher_name |
+--------+--------+------------+-------------+
|     10 | CLARK  | AAA        | KING        |
|   NULL | KING   | CLARK      | MILLER      |
|   NULL | MILLER | KING       | ZZZ         |
|     20 | ADAMS  | AAA        | FORD        |
|   NULL | FORD   | ADAMS      | JONES       |
|   NULL | JONES  | FORD       | SCOTT       |
|   NULL | SCOTT  | JONES      | SMITH       |
|   NULL | SMITH  | SCOTT      | ZZZ         |
|     30 | ALLEN  | AAA        | BLAKE       |
|   NULL | BLAKE  | ALLEN      | JAMES       |
|   NULL | JAMES  | BLAKE      | MARTIN      |
|   NULL | MARTIN | JAMES      | TURNER      |
|   NULL | TURNER | MARTIN     | WARD        |
|   NULL | WARD   | TURNER     | ZZZ         |
+--------+--------+------------+-------------+
14 rows in set (0.00 sec)

first_value、last_value、nth_value

first_value、last_value语法:

first_value(expression) over w 
window w as  (partition-clause order-by-clause windowing-clause)
last_value(expression) over w
window w as  (partition-clause order-by-clause windowing-clause)

nth_value语法:

nth_value (measure, n) [ from first | from last ] [ respect nulls | ignore nulls ]
over  w
window w as  (partitioning-clause order-by-clause windowing-clause) 

/*
需求:求每个部门工资最高的和工资最低的以及工资第二高的
*/

-- 默认不带开窗子句,从第一行到当前行
select a.empno,a.deptno,a.sal,
       first_value(a.sal)  over w as 'first',
       last_value(a.sal) over w as 'last',
       nth_value(a.sal,2) over w as 'top_2'
  from emp a
  window w  as (partition by a.deptno order by sal)
;

-- rows between unbounded preceding and current row  从第一行到当前行
select a.empno,a.deptno,a.sal,
       first_value(a.sal)  over w as 'first',
       last_value(a.sal) over w as 'last',
       nth_value(a.sal,2) over w as 'top_2'
  from emp a
   window w  as (partition by a.deptno order by sal rows between unbounded preceding and current row)
;
  

-- rows between unbounded preceding and unbounded following 从第一行到最后一行
 select a.empno,a.deptno,a.sal,
       first_value(a.sal)  over w as 'first',
       last_value(a.sal) over w as 'last',
       nth_value(a.sal,2) over w as 'top_2'
  from emp a
 window w  as (partition by a.deptno order by sal rows between unbounded preceding and unbounded following)
; 
 
 -- 1 preceding and 1 following   当前行的前一行到当前行的后一行 
  select a.empno,a.deptno,a.sal,
       first_value(a.sal)  over w as 'first',
       last_value(a.sal) over w as 'last',
       nth_value(a.sal,2) over w as 'top_2'
  from emp a
 window w  as (partition by a.deptno order by sal rows between 1 preceding and 1 following)
; 
mysql> -- 默认不带开窗子句,从第一行到当前行
mysql> select a.empno,a.deptno,a.sal,
    ->        first_value(a.sal)  over w as 'first',
    ->        last_value(a.sal) over w as 'last',
    ->        nth_value(a.sal,2) over w as 'top_2'
    ->   from emp a
    ->   window w  as (partition by a.deptno order by sal)
    -> ;
+-------+--------+---------+---------+---------+---------+
| empno | deptno | sal     | first   | last    | top_2   |
+-------+--------+---------+---------+---------+---------+
|  7934 |     10 | 1300.00 | 1300.00 | 1300.00 |    NULL |
|  7782 |     10 | 2450.00 | 1300.00 | 2450.00 | 2450.00 |
|  7839 |     10 | 5000.00 | 1300.00 | 5000.00 | 2450.00 |
|  7369 |     20 |  800.00 |  800.00 |  800.00 |    NULL |
|  7876 |     20 | 1100.00 |  800.00 | 1100.00 | 1100.00 |
|  7566 |     20 | 2975.00 |  800.00 | 2975.00 | 1100.00 |
|  7788 |     20 | 3000.00 |  800.00 | 3000.00 | 1100.00 |
|  7902 |     20 | 3000.00 |  800.00 | 3000.00 | 1100.00 |
|  7900 |     30 |  950.00 |  950.00 |  950.00 |    NULL |
|  7521 |     30 | 1250.00 |  950.00 | 1250.00 | 1250.00 |
|  7654 |     30 | 1250.00 |  950.00 | 1250.00 | 1250.00 |
|  7844 |     30 | 1500.00 |  950.00 | 1500.00 | 1250.00 |
|  7499 |     30 | 1600.00 |  950.00 | 1600.00 | 1250.00 |
|  7698 |     30 | 2850.00 |  950.00 | 2850.00 | 1250.00 |
+-------+--------+---------+---------+---------+---------+
14 rows in set (0.00 sec)

mysql>
mysql> -- rows between unbounded preceding and current row  从第一行到当前行
mysql> select a.empno,a.deptno,a.sal,
    ->        first_value(a.sal)  over w as 'first',
    ->        last_value(a.sal) over w as 'last',
    ->        nth_value(a.sal,2) over w as 'top_2'
    ->   from emp a
    ->    window w  as (partition by a.deptno order by sal rows between unbounded preceding and current row)
    -> ;
+-------+--------+---------+---------+---------+---------+
| empno | deptno | sal     | first   | last    | top_2   |
+-------+--------+---------+---------+---------+---------+
|  7934 |     10 | 1300.00 | 1300.00 | 1300.00 |    NULL |
|  7782 |     10 | 2450.00 | 1300.00 | 2450.00 | 2450.00 |
|  7839 |     10 | 5000.00 | 1300.00 | 5000.00 | 2450.00 |
|  7369 |     20 |  800.00 |  800.00 |  800.00 |    NULL |
|  7876 |     20 | 1100.00 |  800.00 | 1100.00 | 1100.00 |
|  7566 |     20 | 2975.00 |  800.00 | 2975.00 | 1100.00 |
|  7788 |     20 | 3000.00 |  800.00 | 3000.00 | 1100.00 |
|  7902 |     20 | 3000.00 |  800.00 | 3000.00 | 1100.00 |
|  7900 |     30 |  950.00 |  950.00 |  950.00 |    NULL |
|  7521 |     30 | 1250.00 |  950.00 | 1250.00 | 1250.00 |
|  7654 |     30 | 1250.00 |  950.00 | 1250.00 | 1250.00 |
|  7844 |     30 | 1500.00 |  950.00 | 1500.00 | 1250.00 |
|  7499 |     30 | 1600.00 |  950.00 | 1600.00 | 1250.00 |
|  7698 |     30 | 2850.00 |  950.00 | 2850.00 | 1250.00 |
+-------+--------+---------+---------+---------+---------+
14 rows in set (0.00 sec)

mysql>
mysql>
mysql> -- rows between unbounded preceding and unbounded following 从第一行到最后一行
mysql>  select a.empno,a.deptno,a.sal,
    ->        first_value(a.sal)  over w as 'first',
    ->        last_value(a.sal) over w as 'last',
    ->        nth_value(a.sal,2) over w as 'top_2'
    ->   from emp a
    ->  window w  as (partition by a.deptno order by sal rows between unbounded preceding and unbounded following)
    -> ;
+-------+--------+---------+---------+---------+---------+
| empno | deptno | sal     | first   | last    | top_2   |
+-------+--------+---------+---------+---------+---------+
|  7934 |     10 | 1300.00 | 1300.00 | 5000.00 | 2450.00 |
|  7782 |     10 | 2450.00 | 1300.00 | 5000.00 | 2450.00 |
|  7839 |     10 | 5000.00 | 1300.00 | 5000.00 | 2450.00 |
|  7369 |     20 |  800.00 |  800.00 | 3000.00 | 1100.00 |
|  7876 |     20 | 1100.00 |  800.00 | 3000.00 | 1100.00 |
|  7566 |     20 | 2975.00 |  800.00 | 3000.00 | 1100.00 |
|  7788 |     20 | 3000.00 |  800.00 | 3000.00 | 1100.00 |
|  7902 |     20 | 3000.00 |  800.00 | 3000.00 | 1100.00 |
|  7900 |     30 |  950.00 |  950.00 | 2850.00 | 1250.00 |
|  7521 |     30 | 1250.00 |  950.00 | 2850.00 | 1250.00 |
|  7654 |     30 | 1250.00 |  950.00 | 2850.00 | 1250.00 |
|  7844 |     30 | 1500.00 |  950.00 | 2850.00 | 1250.00 |
|  7499 |     30 | 1600.00 |  950.00 | 2850.00 | 1250.00 |
|  7698 |     30 | 2850.00 |  950.00 | 2850.00 | 1250.00 |
+-------+--------+---------+---------+---------+---------+
14 rows in set (0.00 sec)

mysql>
mysql>  -- 1 preceding and 1 following   当前行的前一行到当前行的后一行
mysql>   select a.empno,a.deptno,a.sal,
    ->        first_value(a.sal)  over w as 'first',
    ->        last_value(a.sal) over w as 'last',
    ->        nth_value(a.sal,2) over w as 'top_2'
    ->   from emp a
    ->  window w  as (partition by a.deptno order by sal rows between 1 preceding and 1 following)
    -> ;
+-------+--------+---------+---------+---------+---------+
| empno | deptno | sal     | first   | last    | top_2   |
+-------+--------+---------+---------+---------+---------+
|  7934 |     10 | 1300.00 | 1300.00 | 2450.00 | 2450.00 |
|  7782 |     10 | 2450.00 | 1300.00 | 5000.00 | 2450.00 |
|  7839 |     10 | 5000.00 | 2450.00 | 5000.00 | 5000.00 |
|  7369 |     20 |  800.00 |  800.00 | 1100.00 | 1100.00 |
|  7876 |     20 | 1100.00 |  800.00 | 2975.00 | 1100.00 |
|  7566 |     20 | 2975.00 | 1100.00 | 3000.00 | 2975.00 |
|  7788 |     20 | 3000.00 | 2975.00 | 3000.00 | 3000.00 |
|  7902 |     20 | 3000.00 | 3000.00 | 3000.00 | 3000.00 |
|  7900 |     30 |  950.00 |  950.00 | 1250.00 | 1250.00 |
|  7521 |     30 | 1250.00 |  950.00 | 1250.00 | 1250.00 |
|  7654 |     30 | 1250.00 | 1250.00 | 1500.00 | 1250.00 |
|  7844 |     30 | 1500.00 | 1250.00 | 1600.00 | 1500.00 |
|  7499 |     30 | 1600.00 | 1500.00 | 2850.00 | 1600.00 |
|  7698 |     30 | 2850.00 | 1600.00 | 2850.00 | 2850.00 |
+-------+--------+---------+---------+---------+---------+
14 rows in set (0.00 sec)

percent_rank、CUME_DIST

percent_rank语法:

percent_rank() over w
window w as  ([partition-by-clause] [order-by-clause] )

CUME_DIST语法

cume_dist() over w
window w as  ([partition-by-clause] [order-by-clause] )

percent_rank:
– percent_rank函数以0到1之间的分数形式返回某个值在数据分区中的排名
– percent_rank的计算公式为(rank-1)/(n-1)

CUME_DIST:
–一个5行的组中,返回的累计分布值为0.2,0.4,0.6,0.8,1.0;
–注意对于重复行,计算时取重复行中的最后一行的位置。
 

SELECT a.empno,
       a.ename,
       a.deptno,
       a.sal,
       percent_rank() over w as 'num',
       cume_dist() over w as 'cume'
  FROM emp a
  window w  as (PARTITION BY a.deptno ORDER BY a.sal DESC)
;
mysql> SELECT a.empno,
    ->        a.ename,
    ->        a.deptno,
    ->        a.sal,
    ->        percent_rank() over w as 'num',
    ->        cume_dist() over w as 'cume'
    ->   FROM emp a
    ->   window w  as (PARTITION BY a.deptno ORDER BY a.sal DESC);
+-------+--------+--------+---------+------+---------------------+
| empno | ename  | deptno | sal     | num  | cume                |
+-------+--------+--------+---------+------+---------------------+
|  7839 | KING   |     10 | 5000.00 |    0 |  0.3333333333333333 |
|  7782 | CLARK  |     10 | 2450.00 |  0.5 |  0.6666666666666666 |
|  7934 | MILLER |     10 | 1300.00 |    1 |                   1 |
|  7788 | SCOTT  |     20 | 3000.00 |    0 |                 0.4 |
|  7902 | FORD   |     20 | 3000.00 |    0 |                 0.4 |
|  7566 | JONES  |     20 | 2975.00 |  0.5 |                 0.6 |
|  7876 | ADAMS  |     20 | 1100.00 | 0.75 |                 0.8 |
|  7369 | SMITH  |     20 |  800.00 |    1 |                   1 |
|  7698 | BLAKE  |     30 | 2850.00 |    0 | 0.16666666666666666 |
|  7499 | ALLEN  |     30 | 1600.00 |  0.2 |  0.3333333333333333 |
|  7844 | TURNER |     30 | 1500.00 |  0.4 |                 0.5 |
|  7521 | WARD   |     30 | 1250.00 |  0.6 |  0.8333333333333334 |
|  7654 | MARTIN |     30 | 1250.00 |  0.6 |  0.8333333333333334 |
|  7900 | JAMES  |     30 |  950.00 |    1 |                   1 |
+-------+--------+--------+---------+------+---------------------+
14 rows in set (0.00 sec)

ntile

Ntile语法:

Ntile(expr) OVER w
window w as   ([ query_partition_clause ] order_by_clause)

Ntile 把数据行分成N个桶。每个桶会有相同的行数,正负误差为1

将员工表emp按照工资分为2、3个桶

-- 分成2个桶
SELECT ENAME, SAL, NTILE(2) OVER w as 'n' FROM EMP
window w  as (ORDER BY SAL ASC)
;

-- 分成3个桶
SELECT ENAME, SAL, NTILE(3) OVER w as 'n' FROM EMP
window w  as (ORDER BY SAL ASC)
;

mysql> -- 分成2个桶
mysql> SELECT ENAME, SAL, NTILE(2) OVER w as 'n' FROM EMP
    -> window w  as (ORDER BY SAL ASC)
    -> ;
+--------+---------+------+
| ENAME  | SAL     | n    |
+--------+---------+------+
| SMITH  |  800.00 |    1 |
| JAMES  |  950.00 |    1 |
| ADAMS  | 1100.00 |    1 |
| WARD   | 1250.00 |    1 |
| MARTIN | 1250.00 |    1 |
| MILLER | 1300.00 |    1 |
| TURNER | 1500.00 |    1 |
| ALLEN  | 1600.00 |    2 |
| CLARK  | 2450.00 |    2 |
| BLAKE  | 2850.00 |    2 |
| JONES  | 2975.00 |    2 |
| SCOTT  | 3000.00 |    2 |
| FORD   | 3000.00 |    2 |
| KING   | 5000.00 |    2 |
+--------+---------+------+
14 rows in set (0.00 sec)

mysql>
mysql> -- 分成3个桶
mysql> SELECT ENAME, SAL, NTILE(3) OVER w as 'n' FROM EMP
    -> window w  as (ORDER BY SAL ASC)
    -> ;
+--------+---------+------+
| ENAME  | SAL     | n    |
+--------+---------+------+
| SMITH  |  800.00 |    1 |
| JAMES  |  950.00 |    1 |
| ADAMS  | 1100.00 |    1 |
| WARD   | 1250.00 |    1 |
| MARTIN | 1250.00 |    1 |
| MILLER | 1300.00 |    2 |
| TURNER | 1500.00 |    2 |
| ALLEN  | 1600.00 |    2 |
| CLARK  | 2450.00 |    2 |
| BLAKE  | 2850.00 |    2 |
| JONES  | 2975.00 |    3 |
| SCOTT  | 3000.00 |    3 |
| FORD   | 3000.00 |    3 |
| KING   | 5000.00 |    3 |
+--------+---------+------+
14 rows in set (0.00 sec)

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/345848.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

matlab进行双目标定获取双目参数并打印教程

文章目录前言1.打开matlab进行双目标定2.获取想要的参数前言 在相同的标定算法和标定参数下&#xff0c;Python和Matlab的标定精度是相同的。因为标定精度主要取决于标定算法和标定参数的质量&#xff0c;而不是编程语言的选择。 不同的编程语言可能使用不同的库或实现细节&…

Hackergame 2020

3.Hackergame 2020 1.签到 url&#xff1a;http://202.38.93.111:10000/ 打开签到题页面&#xff0c;拖动滑杆&#xff0c;如果将滑杆滑动到最左边&#xff0c;提交 0&#xff0c;那么我们会得到成功的返回&#xff0c;但是没有 flag 尝试手动提交一些非整数的值&#xff0c…

HTML+CSS

HTML技术 什么是HTML Hyper Text Markup Language HTML&#xff1a;超文本标记语言&#xff0c;内部全部是一些不同的标记符号。 通俗的来讲&#xff1a;其实就是“网页”。 HTML 网页 网页的特点&#xff1a; 1、所有的网页都是通过【浏览器】来进行解析的。2、所有的网…

【MySQL】子查询

这里写自定义目录标题子查询1、子查询的基本使用2、 单行子查询2.1、单行比较查询2.2、HAVING 中的子查询2.3、CASE中的子查询3、多行子查询4、相关子查询5、EXISTS 与 NOT EXISTS关键字子查询 子查询指一个查询语句嵌套在另一个查询语句内部的查询&#xff0c;这个特性从MySQ…

算法笔记(四)—— 排序算法总结及链表

排序算法稳定性 值相同的元素排序结束后能否保持相对秩序不变。 冒泡排序具有稳定性&#xff08;相等时不交换&#xff09;。 插入排序具有稳定性。 归并排序具有稳定性&#xff08;merge的时候&#xff0c;相等时先拷贝左边的&#xff0c;小和问题让其丧失了稳定性&#x…

557. 反转字符串中的单词 III

给定一个字符串 s &#xff0c;你需要反转字符串中每个单词的字符顺序&#xff0c;同时仍保留空格和单词的初始顺序。 方法一&#xff1a;使用额外空间 思路与算法 开辟一个新字符串。然后从头到尾遍历原字符串&#xff0c;直到找到空格为止&#xff0c;此时找到了一个单词&a…

Http中你必须知道那点事

1, HTTP 1.1 简介 HTTP概念 HyperText Transfer Protocol&#xff0c;超文本传输协议&#xff0c;规定了浏览器和服务器之间数据传输的规则。 数据传输的规则指的是请求数据和响应数据需要按照指定的格式进行传输。如果想知道具体的格式&#xff0c;可以打开浏览器&#xf…

2、线程、块和网格

目录一、线程、块、网格概念二、代码分析2.1 打印第一个线程块的第一线程2.2 打印当前线程块的当前线程2.3 获取当前是第几个线程一、线程、块、网格概念 CUDA的软件架构由网格&#xff08;Grid&#xff09;、线程块&#xff08;Block&#xff09;和线程&#xff08;Thread&am…

Allegro如何设置导入Subdrawing可自由选择目录操作指导

Allegro如何设置导入Subdrawing可自由选择目录操作指导 用Allgro做PCB设计的时候,导入Subdrawing是非常常用的功能,在导入Subdrawing的时候,通常需要把Subdrawing文件放在需要导入PCB的相同目录下,不能自由选择,如下图 但是Allegro是支持自由选择目录的,只需按照下方的步…

Sphinx文档生成工具(一)

Sphinx在项目中部署应用 一、将安装的Sphinx发布 创建FindSphinx.cmake&#xff0c;这个名字只能是这个 find_program(SPHINX_EXECUTABLE NAMES sphinx-buildHINTS$ENV{SPHINX_DIR}HINTS ${SPHINX_ROOT}/binPATH_SUFFIXES binDOC "Sphinx documentation generator"…

企业为什么需要绩效管理软件?

随着经济的发展&#xff0c;企业的竞争日益激烈&#xff0c;“纸上谈兵”的绩效考核机制已经远远不能满足企业管理的需要。因此&#xff0c;企业绩效管理软件的重要性也日益凸显。 绩效管理软件可以提高企业管理效率、提高HR工作效率、提高员工工作能力。 今天就来给大家详细…

【C++】从0到1入门C++编程学习笔记 - 实战篇:演讲比赛流程管理系统

文章目录一、演讲比赛程序需求1.1 比赛规则1.2 程序功能1.3 程序效果图&#xff1a;二、项目创建2.1 创建项目2.2 添加文件三、创建管理类3.1创建文件3.2 头文件实现3.3 源文件实现四、菜单功能4.1 添加成员函数4.2 菜单功能实现4.3 测试菜单功能五、退出功能5.1 提供功能接口5…

RiproV2主题右侧美化右侧导航美化RiproV2主题右侧个人中心美化保持常驻

背景: RiproV2主题右侧美化右侧导航美化RiproV2主题右侧个人中心美化保持常驻 原样式没有文字只有图标,修改之后有文字,并且保持常驻在右侧,不随页面滚动而滚动 下面是楼主网站优化后的效果:

Linux中定时监控Tomcat服务器进程并在进程结束时重启Tomcat服务器

目录一、问题二、解决方法1、创建定时任务文件2、修改Tomcat的部分文件3、添加系统的定时调度4、执行monitor.sh文件5、查看脚本执行的日志文件一、问题 当我们的Tomcat配置完成后投入使用后&#xff0c;在用户使用一定时间后&#xff0c;Tomcat可能会出现一些问题导致进程结束…

mybatis-plus ---2

mybatis-plus插件 官网地址 分页插件 MyBatis Plus自带分页插件&#xff0c;只要简单的配置即可实现分页功能 配置并使用自带分页插件 Configuration MapperScan("com.itzhh.mapper")//可以将主类中的注解移到此处 public class MybatisPlusConfig {Beanpublic …

MySQL数据库调优————OPTIMIZER_TRACE详解

OPTIMIZER_TRACE是MySQL5.6引入的一项跟踪功能&#xff0c;它可以跟踪优化器做出的各种决策&#xff08;比如访问表的方法、各种开销计算、各种转换等&#xff09;&#xff0c;并将跟踪结果记录到INFORMATION_SCHEMA.OPTIMIZER_TRACE表中。此功能默认关闭&#xff0c;开启后 &a…

工业智能网关解决方案:物联网仓储环境监测系统

仓储是连接生产、供应和销售的中转系统&#xff0c;对于促进生产、提高效率有着重要的辅助作用。对于很多大型工厂或食品厂来说&#xff0c;需要对仓储环境进行严控的控制&#xff0c;以确保产品或食品的质量&#xff0c;避免不必要的产品损耗&#xff0c;提高产品存管的水平。…

Redisson分布式锁基本使用及可重入锁原理分析

基本使用 1、引入依赖 <!-- redisson依赖 --><dependency><groupId>org.redisson</groupId><artifactId>redisson</artifactId><version>3.13.6</version></dependency>2、配置redisson客户端 // 将RedissonClie…

【每日随笔】手指训练 ( 手指训练作用 | 哪些人需要手指训练 | 手指操 | 手指康复训练器材 )

文章目录一、手指训练作用二、哪些人需要手指训练三、手指操四、手指康复训练器材产品需求探索 , 研究下手指训练的市场 , 前景 , 是否可以开发 ; 一、手指训练作用 手指训练作用 : 改善 上肢协调性手眼 协调性训练提高 手指 抓握 能力提高 手指 灵活性提高 上肢运动 准确性 和…

vscode下进行python配置及编码,新手学习

介绍在开发工具vscode下进行python的配置及编码&#xff0c;新手来学。 1、首先下载及安装最新版本的vscode。 【VSCode最新版本下载安装详细教程&#xff08;win10)】 2、下载安装最新版本python&#xff0c;也可以根据需要下载自己需要的版本。 【python3.11下载安装详细…