[LeetCode]577. Employee Bonus 员工奖金

Select all employee‘s name and bonus whose bonus is < 1000.

Table:Employee

+-------+--------+-----------+--------+
| empId |  name  | supervisor| salary |
+-------+--------+-----------+--------+
|   1   | John   |  3        | 1000   |
|   2   | Dan    |  3        | 2000   |
|   3   | Brad   |  null     | 4000   |
|   4   | Thomas |  3        | 4000   |
+-------+--------+-----------+--------+
empId is the primary key column for this table.

Table: Bonus

+-------+-------+
| empId | bonus |
+-------+-------+
| 2     | 500   |
| 4     | 2000  |
+-------+-------+
empId is the primary key column for this table.

Example ouput:

+-------+-------+
| name  | bonus |
+-------+-------+
| John  | null  |
| Dan   | 500   |
| Brad  | null  |
+-------+-------+

选出所有奖金<1000元的雇员姓名及奖金数额

解法1:

# Write your MySQL query statement below
SELECT name, bonus
FROM Employee LEFT JOIN Bonus USING (empId)
WHERE IFNULL(bonus, 0) < 1000  

解法2:

select name, bonus
from
Employee e left join Bonus b
on e.empId = b.empId
where bonus < 1000 or bonus is null

  

原文地址:https://www.cnblogs.com/lightwindy/p/9698931.html

时间: 2024-11-08 07:17:44

[LeetCode]577. Employee Bonus 员工奖金的相关文章

[LeetCode]690. Employee Importance员工重要信息

哈希表存id和员工数据结构 递归获取信息 public int getImportance(List<Employee> employees, int id) { Map<Integer,Employee> map = new HashMap<>(); for (int i = 0; i < employees.size(); i++) { Employee temp = employees.get(i); map.put(temp.id,temp); } ret

员工奖金自己定

朋友在南方开公司,规模虽然不大,但他把握住了市场机遇,前一年的业绩非常不错.前几天通电话时,他开心地说,终于可以好好奖励跟着自己一起创业的兄弟们了.他准备将除扩大规模的费用以外的大部分利润,分给员工当奖金,好让大家更有干劲.奖金数目的确不少.我不禁想到一个问题,仅仅是数量多就能够让人满意吗?古话说"不患寡而患不均",人们抱怨的往往不是数量少而是分配的不公平.一方面,老板就算明察秋毫.秉公无私,也不能保证分配时不失偏颇:另一方面,人性的弱点注定每个人更容易看到自己的付出而忽视别人的贡献,

690. Employee Importance 员工重要性

You are given a data structure of employee information, which includes the employee's unique id, his importance value and his direct subordinates' id. For example, employee 1 is the leader of employee 2, and employee 2 is the leader of employee 3. Th

Leetcode 759. Employee Free Time

思路:区域覆盖问题.一个自然的想法是将每个员工的工作时间段看做一个木棒,每个木棒的长度就是这个时间段的时长.然后按照木棒的起始位置升序排列,接着由低位置向高位置一个木棒一个木棒的看过去.如果当前木棒的末节点的位置>下一个木棒的头节点位置,那么这两个节点就是一个free time的开头和结尾:如果当前木棒的末节点位置<=下一个木棒的头节点位置,那么更新当前木棒的末节点位置为max(当前木棒的末节点位置,下一个木棒的头节点位置). 1 /** 2 * Definition for an inter

LeetCode - 690. Employee Importance

You are given a data structure of employee information, which includes the employee's unique id, his importance value and his directsubordinates' id. For example, employee 1 is the leader of employee 2, and employee 2 is the leader of employee 3. The

[LeetCode] 690. Employee Importance_Easy tag: BFS

You are given a data structure of employee information, which includes the employee's unique id, his importance value and his directsubordinates' id. For example, employee 1 is the leader of employee 2, and employee 2 is the leader of employee 3. The

输入员工的销售额,自动计算出他的奖金

某企业员工奖金与员工的销售挂钩,其规则如下(超出部分):销售额 <= 10万 10%10万 < 销售额 <= 20万 7.5%20万 < 销售额 <= 40万 5%40万 < 销售额 <= 60万 3%60万 < 销售额 <= 100万 1.5%100万 < 销售额 1%请书写程序,实现根据输入员工的销售额,自动计算出他的奖金 #include <stdio.h> void main(){ double m,s,d; printf(&

【sql】leetcode习题 (共 42 题)

p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica } [175]Combine Two Tables [176]Second Highest Salary [177]Nth Highest Salary [178]Rank Scores [180]Consecutive Numbers [181]Employees Earning More Than Their Managers [182]Duplicate Email

23.奖金(拓扑排序)

奖金(拓扑排序) [问题描述] 由于无敌的凡凡在2005年世界英俊帅气男总决选中胜出,Yali Company总经理Mr.Z心情好,决定给每位员工发奖金.公司决定以每个人本年在公司的贡献为标准来计算他们得到奖金的多少.于是Mr.Z下令召开m方会谈.每位参加会谈的代表提出了自己的意见:“我认为员工a的奖金应该比b高!”Mr.Z决定要找出一种奖金方案,满足各位代表的意见,且同时使得总奖金数最少.每位员工奖金最少为100元. [输入格式] 第一行两个整数n,m,表示员工总数和代表数:以下m行,每行2个