LeetCode-181. 超过经理收入的员工( Employees Earning More Than Their Managers)。

中级工程师基础SQL试题 一、查询员工的全名,email和电话 SELECT concat(first_name,',',last_name),email,phone_int //将employees表的所有员工的last_name和first_name拼接起来作为Name FROM employees; 二、查询所有员工的全名,月薪和年薪(月薪*12) SELECT first_name,last_name,salary,salary*12 FROM employees; 三、查询所有员工的全名,月薪和年终奖(年薪*comm 阅读详情

Employee 表包含所有员工,他们的经理也属于员工。每个员工都有一个 Id,此外还有一列对应员工的经理的 Id。

+----+-------+--------+-----------+
| Id | Name  | Salary | ManagerId |
+----+-------+--------+-----------+
| 1  | Joe   | 70000  | 3         |
| 2  | Henry | 80000  | 4         |
| 3  | Sam   | 60000  | NULL      |
| 4  | Max   | 90000  | NULL      |
+----+-------+--------+-----------+
给定 Employee 表,编写一个 SQL 查询,该查询可以获取收入超过他们经理的员工的姓名。在上面的表格中,Joe 是唯一一个收入超过他的经理的员工。

+----------+
| Employee |
+----------+
| Joe      |
+----------+

题目来源:力扣(LeetCode)
链接:https://leetcode-cn.com/problems/employees-earning-more-than-their-managers

解题:

首先根据经理id查询经理的收入,然后对比查找比经理收入高。两个条件查询:

SELECT
    a.Name AS 'Employee'
FROM
    Employee AS a,
    Employee AS b
WHERE
    a.ManagerId = b.Id
        AND a.Salary > b.Salary;

可以使用join语句:

SELECT
    a.Name AS 'Employee'
FROM
    Employee AS a JOIN
    Employee AS b
ON
    a.ManagerId = b.Id
        AND a.Salary > b.Salary;

 

智能优化算法-北方苍鹰优化算法(NGO)(附源码) 北方苍鹰优化算法 (Northern Goshawk Optimizer, NGO) 是一种基于群体智能的元启发式优化算法,它模拟了北方苍鹰(Northern Goshawk)的捕食行为、领地行为以及社交互动,用于解决复杂的优化问题。总之,NGO作为一种新颖的优化算法,在处理复杂优化问题方面展现出了潜力。随着进一步的研究和应用,NGO有望成为解决实际问题的有效工具。 阅读详情

相关推荐

USB接口ESD防护设计实战:从金属外壳到信号线的完整避坑指南

本文深入探讨USB接口ESD防护设计的实战要点,聚焦金属外壳作为ESD能量泄放关键通道的处理策略。文章详细解析了从外壳接地路径控制、信号线TVS管选型与布局,到PCB分区及电源线滤波等完整设计流程,旨在帮助硬件工程师构建系统级防护,避免常见设计误区,确保产品通过严苛的静电测试。

k8l9m0n的博客 482

LeetCode刷题之旅——(数据库)181. 超过经理收入的员工

181. 超过经理收入的员工 Employee 表包含所有员工,他们的经理也属于员工。每个员工都有一个 Id,此外还有一列对应员工的经理的 Id。 ±—±------±-------±----------+ | Id | Name | Salary | ManagerId | ±—±------±-------±----------+ | 1 | Joe | 70000 | 3 ...

boyames的博客 644

LEF文件介绍及其生成

介绍LEF文件及其生成方法

weixin_43249158的博客 3万+

大数据开发工程师之SQL面试题(二)

sql面试题(二) 请你查找employees里最晚入职员工的所有信息, select * from employees WHERE hire_date in (select max(hire_date) from employees ); select * from employees order by hire_date DESC limit 1; 有一个员工employees表简况如下: 请你查找employees里入职员工时间排名倒数第三的员工所有信

北岭清酒 1384

ADS 使用教程(一)Workspace, Library and Cell

简要介绍ADS的基本内容

Dirge19的博客 6619

Wireshark时间分析实战:精准调试网络延迟与时间同步问题

本文深入探讨了Wireshark在网络延迟与时间同步问题分析中的核心应用。通过实战案例,详细讲解了如何设置时间显示格式、利用时间参考点量化关键路径延迟,以及运用时间平移功能校正错位时间轴。掌握这些时间分析技巧,能帮助网络工程师精准定位隐藏于数据包时序中的性能瓶颈与故障根源。

weixin_29290963的博客 263

SQL-每日一题【181.超过经理收入的员工】

Employee编写一个SQL查询来查找收入比经理高的员工。以返回结果表。查询结果格式如下所示。

lucky_1314520的博客 388

Windows下Nginx发布DEM地形瓦片数据全流程(含Cesium调用避坑指南)

本文详细介绍了在Windows环境下使用Nginx发布DEM地形瓦片数据的完整流程,并提供了Cesium前端调用的详细配置与避坑指南。重点讲解了Nginx的核心配置、跨域问题解决以及CesiumTerrainProvider的关键参数设置,帮助开发者快速搭建本地地形服务,实现高效的三维地形可视化。

weixin_29212867的博客 435

想要精通算法和SQL的成长之路 - 超过经理收入的员工(SQL)

子查询这种写法,其实就是相当于自连接的一种变相写法了。宏观角度来看,我们使用了两张一模一样的表,分别命名为。存在着父子关系,因此我们需要用到两张。不过,我们的题目里面的名称,也就是。查询来查找收入比经理高的员工。那么宏观角度来看,下面的两个。中的一张表单独提取出来罢了。这里说明一下,为什么上面的。该表的每一行都表示雇员的。语句的查询字段都是来自于。、姓名、工资和经理的。

Zong_0915的博客 846

Linux运维人,该醒醒了,2019年要变天了

外界都说运维只是处于被动低效率手工救火的状态,企业对其重视程度不高,提起运维很多人能联想到的字眼就有“苦逼”、“辛苦”、“加班”、“背锅”。在大数据、人工智能、容器技术的强力加持下,运维这个传统的技术工种已经从“机械劳动”这样的刻板印象中蜕变出来,成为了任何一家技术公司所必须依赖和大力投入的核心技术能力。 现在,运维人员的发展前景也开始让很多程序员眼羡,作为Linux运维人员的你:这一年,你的L...

qq_43083284的博客 1万+

Codex 100个真实案例 - 用AI绘制CAD机械图纸(工程师看了直呼内行)

本案例将展示如何用 Codex 生成 Python 脚本,通过 `ezdxf` 库绘制标准 DXF 格式的 CAD 机械图纸。我们会从零开始,逐步实现直线、圆、圆弧、标注等基本图形元素,最终绘制出一张包含主视图、俯视图、尺寸标注、标题栏和技术要求的完整法兰盘零件图。还会演示参数化批量生成不同规格零件图和自动 BOM 物料清单,生成的 DXF 文件可直接在 AutoCAD、FreeCAD 中打开。全程用自然语言驱动 Codex,工程师看完直接上手!

yueyeguzhuo的专栏 2088

[SQL]LeetCode181. 超过经理收入的员工 | Employees Earning More Than Their Managers

★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★➤微信公众号:山青咏芝(shanqingyongzhi)➤博客园地址:山青咏芝(https://www.cnblogs.com/strengthen/)➤GitHub地址:https://github.com/strengthen/LeetCode➤原文地址:https://www.cnblogs.com/streng...

weixin_30894389的博客 185

优化算法 | 赏金猎人优化算法(Bounty Hunter Optimizer, BHO)及其在多无人机移动边缘计算与路径规划中的应用(附matlab源代码)

移动边缘计算(Mobile Edge Computing, MEC)通过将计算资源下沉至网络边缘,有效解决了物联网终端设备计算能力不足与能耗受限的问题。无人机(Unmanned Aerial Vehicle, UAV)因其高机动性、灵活部署和广域覆盖等优势,被广泛用作MEC的移动服务器平台。多无人机辅助MEC系统的核心优化问题在于:如何在满足任务处理时延约束和无人机能量限制的前提下,联合优化无人机的三维飞行轨迹、任务卸载决策与计算资源分配,以最小化系统总能耗或最大化任务完成效率。

尘世冰封的专栏 224

LeetCode 181. Employees Earning More Than Their Managers 超过经理收入的员工(数据库)

题目: 解答: 解法一: 生成两个实例对象进行内交,通过比对ManagerId和Id,限制条件是一个Salary大于另一个即可 select Name Employee from Employee e1 where e1.Salary> (select e2.Salary from Employee e2 where e1.ManagerId=e2.Id) 解法二: 通过 where 来...

qq_41878358的博客 221

android 蓝牙通讯demo

android 下蓝牙通讯demo,实现了发现蓝牙,使能蓝牙,通过蓝牙发送消息。

visio安装包

Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。

Leetcode每日一题:181.employees-earning-more-than-their-managers(超过经理收入的员工)

思路:回忆起了SQL语句之后,一道道题就感觉挺容易了,这道题直接就是一个内连接就能解决; 代码: # Write your MySQL query statement below select e1.Name as Employee from Employee e1,Employee e2 where e1.ManagerId=e2.Id and e1.Salary>e2.Salary ...

CodeLuweir 的博客 238

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

leetcode 181. Employees Earning More Than Their Managers

题意:查询员工工资大于该员工经理的工资的姓名 题目链接:https://leetcode.com/problems/employees-earning-more-than-their-managers/ select Name from Employee as x where x.Salary > (select y.Salary from

zyh 745

文档:亲测可用解决vnc灰屏,黑屏,鼠标大黑叉情况

主要解决vnc-viewer灰屏,黑屏,鼠标大黑叉等现象,详细见文档。

LeetCode //MySQL - 181. Employees Earning More Than Their Managers

【代码】LeetCode //MySQL - 181. Employees Earning More Than Their Managers。

Made in Code 1120

LeetCode SQL 181. Employees Earning More Than Their Managers【连接】简单

The Employee table holds all employees including their managers. Every employee has an Id, and there is also a column for the manager Id. +----+-------+--------+-----------+ | Id | Name | Salary | ManagerId | +----+-------+--------+-----------+ | 1 | Joe

memcpy0的博客 368

【Leetcode Database】Employees Earning More Than Their Managers

题目: The Employee table holds all employees including their managers. Every employee has an Id, and there is also a column for the manager Id. +----+-------+--------+-----------+ | Id | Name |

chenyancun2011的专栏 517

LeetCode 181. Employees Earning More Than Their Managers (sql)

181.Employees Earning More Than Their Managers Easy SQL Schema TheEmployeetable holds all employees including their managers. Every employee has an Id, and there is also a column for the manager...

da_kao_la的博客 290

[leetcode] 181. Employees Earning More Than Their Managers

sql

Halfopen的专栏 7384

LeetCode:181. Employees Earning More Than Their Managers

The Employee table holds all employees including their managers. Every employee has an Id, and there is also a column for the manager Id. +----+-------+--------+-----------+ | Id | Name | Salary |

DieHorseSpecial的博客 472

【Leetcode】Employees Earning More Than Their Managers

题目链接:https://leetcode.com/problems/employees-earning-more-than-their-managers/题目: The Employee table holds all employees including their managers. Every employee has an Id, and there is also a column

业精于勤,荒于嬉 1646

[LeetCode]Employees Earning More Than Their Managers

The Employee table holds all employees including their managers. Every employee has an Id, and there is also a column for the manager Id. +----+-------+--------+-----------+ | Id | Name | Salar...

weixin_33736832的博客 252

leetcode Employees Earning More Than Their Managers题解

题目描述: The Employee table holds all employees including their managers. Every employee has an Id, and there is also a column for the manager Id. +----+-------+--------+-----------+ | Id | Name | Sa...

leo_weile的博客 230

Leetcode 181. Employees Earning More Than Their Managers | SQL Pandas 解法

Leetcode 181. Employees Earning More Than Their Managers | SQL Pandas 解法 Easy The Employee table holds all employees including their managers. Every employee has an Id, and there is also a column for the manager Id. +----+-------+--------+-----------+ | I

Dandelion63的博客 296
上一篇: LeetCode-180. 连续出现的数字( Consecutive Numbers)。
下一篇: LeetCode-182. 查找重复的电子邮箱( Consecutive Numbers)。
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值