0
点赞
收藏
分享

微信扫一扫

高频SQL 50题(基础版): 员工奖金 | 2023-08-17

爱做梦的夏夏 2023-08-17 阅读 34

问题

表: Activity

+----------------+---------+
| Column Name    | Type    |
+----------------+---------+
| machine_id     | int     |
| process_id     | int     |
| activity_type  | enum    |
| timestamp      | float   |
+----------------+---------+
该表展示了一家工厂网站的用户活动.
(machine_id, process_id, activity_type) 是当前表的主键.
machine_id 是一台机器的ID号.
process_id 是运行在各机器上的进程ID号.
activity_type 是枚举类型 ('start', 'end').
timestamp 是浮点类型,代表当前时间(以秒为单位).
'start' 代表该进程在这台机器上的开始运行时间戳 , 'end' 代表该进程在这台机器上的终止运行时间戳.
同一台机器,同一个进程都有一对开始时间戳和结束时间戳,而且开始时间戳永远在结束时间戳前面.

选出所有 bonus < 1000 的员工的 name 及其 bonus。

输出:
+-------+-------+
| name  | bonus |
+-------+-------+
| John  | null  |
| Dan   | 500   |
| Brad  | null  |
+-------+-------+

解答

# Write your MySQL query statement below
select name, bonus from Employee left join Bonus on Employee.EmpId = Bonus.EmpId where bonus is null or bonus < 1000
举报

相关推荐

0 条评论