题库 软件开发 题目列表 MySQL8中overtime_table结构如下, CREAT...
单选题
MySQL8中overtime_table结构如下,
CREATE TABLE overtime_table (
     employee_name VARCHAR(50) NOT NULL,
     department VARCHAR(50) NOT NULL,
     hours INT NOT NULL,
     PRIMARY KEY (employee_name , department)
 );
分部门查询加班时长最长的employee_name,期望结果如下:
+-------------------+------------+-------+-----------------+
| employee_name     | department | hours |longest_time_name|
+-------------------+------------+-------+-----------------+
| Mary Patterson    | Accounting |    74 | Mary Patterson  |
| Jeff Firrelli     | Accounting |    40 | Mary Patterson  |
| Diane Murphy      | Accounting |    37 | Mary Patterson  |
| Anthony Bow       | Finance    |    66 | Anthony Bow     |
| William Patterson | Finance    |    58 | Anthony Bow     |
| Gerard Bondur     | Finance    |    47 | Anthony Bow     |
+-------------------+------------+-------+-----------------+
以下符合预期的是()
A.
SELECT
    employee_name,
    department,
    hours,
    LAST_VALUE(employee_name) OVER (
        PARTITION BY department
        ORDER BY hours
    ) longest_time_name
FROM
    overtime_table;
B.
SELECT
    employee_name,
    department,
    hours,
    LAST_VALUE(employee_name) OVER (
        PARTITION BY department
        ORDER BY hours DESC
    ) longest_time_name
FROM
    overtime_table;
C.
SELECT
    employee_name,
    department,
    hours,
    FIRST_VALUE(employee_name) OVER (
        PARTITION BY department
        ORDER BY hours DESC
    ) longest_time_name
FROM
    overtime_table;
D.

其他选项均错误

题目信息
校招真题
-
正确率
0
评论
54
点击