当前位置: 首页 > news >正文

广东联通通信建设有限公司 网站关键词推广方式

广东联通通信建设有限公司 网站,关键词推广方式,网站新备案不能访问,邢台做网站流程大家好,我是空空star,本篇带大家了解一道简单的力扣sql练习题。 文章目录前言一、题目:1873. 计算特殊奖金二、解题1.正确示范①提交SQL运行结果2.正确示范②提交SQL运行结果3.正确示范③提交SQL运行结果4.正确示范④提交SQL运行结果5.其他总…

大家好,我是空空star,本篇带大家了解一道简单的力扣sql练习题。

文章目录

  • 前言
  • 一、题目:1873. 计算特殊奖金
  • 二、解题
    • 1.正确示范①
      • 提交SQL
      • 运行结果
    • 2.正确示范②
      • 提交SQL
      • 运行结果
    • 3.正确示范③
      • 提交SQL
      • 运行结果
    • 4.正确示范④
      • 提交SQL
      • 运行结果
    • 5.其他
  • 总结


前言


一、题目:1873. 计算特殊奖金

表: Employees

+-------------+---------+
| 列名        | 类型     |
+-------------+---------+
| employee_id | int     |
| name        | varchar |
| salary      | int     |
+-------------+---------+
employee_id 是这个表的主键。
此表的每一行给出了雇员id ,名字和薪水。

写出一个SQL 查询语句,计算每个雇员的奖金。如果一个雇员的id是奇数并且他的名字不是以’M’开头,那么他的奖金是他工资的100%,否则奖金为0。
Return the result table ordered by employee_id.
返回的结果集请按照employee_id排序。
查询结果格式如下面的例子所示。

输入:
Employees 表:
+-------------+---------+--------+
| employee_id | name    | salary |
+-------------+---------+--------+
| 2           | Meir    | 3000   |
| 3           | Michael | 3800   |
| 7           | Addilyn | 7400   |
| 8           | Juan    | 6100   |
| 9           | Kannon  | 7700   |
+-------------+---------+--------+
输出:
+-------------+-------+
| employee_id | bonus |
+-------------+-------+
| 2           | 0     |
| 3           | 0     |
| 7           | 7400  |
| 8           | 0     |
| 9           | 7700  |
+-------------+-------+

解释:
因为雇员id是偶数,所以雇员id 是2和8的两个雇员得到的奖金是0。
雇员id为3的因为他的名字以’M’开头,所以,奖金是0。
其他的雇员得到了百分之百的奖金。

二、解题

1.正确示范①

提交SQL

select employee_id,
case when employee_id%2=1 and name not like 'M%' then salary 
else 0 end bonus
from Employees
order by employee_id;

运行结果

2.正确示范②

提交SQL

select employee_id,
case when mod(employee_id,2)=1 and left(name,1)!='M' then salary 
else 0 end bonus
from Employees
order by employee_id;

运行结果

3.正确示范③

提交SQL

select employee_id,
if(mod(employee_id,2)=1 and left(name,1)!='M',salary,0) bonus
from Employees
order by employee_id;

运行结果

4.正确示范④

提交SQL

select employee_id,
case when mod(employee_id,2)=0 then 0 
when mod(employee_id,2)=1 and left(name,1)='M' then 0
else salary end bonus
from Employees
order by employee_id;

运行结果

5.其他


总结

正确示范①思路:
如果一个雇员的id是奇数并且他的名字不是以’M’开头,那么他的奖金是他工资的100%,也就是他的工资,否则奖金为0。
采用 case when + %取余 + not like
case when employee_id%2=1 and name not like 'M%' then salary else 0 end
正确示范②思路:
思路同①
采用 case when + mod取余 + left
case when mod(employee_id,2)=1 and left(name,1)!='M' then salary else 0 end
正确示范③思路:
思路同①
采用 if + mod取余 + left
if(mod(employee_id,2)=1 and left(name,1)!='M',salary,0)
正确示范④思路:
雇员id是偶数,则奖金为0,
雇员id是奇数并且他的名字以’M’开头,则奖金为0,
否则奖金是他工资的100%
case when mod(employee_id,2)=0 then 0
when mod(employee_id,2)=1 and left(name,1)='M' then 0
else salary end


文章转载自:
http://sexily.c7623.cn
http://intersensory.c7623.cn
http://quarantine.c7623.cn
http://crepitate.c7623.cn
http://cowcatcher.c7623.cn
http://beijing.c7623.cn
http://afghan.c7623.cn
http://monticulous.c7623.cn
http://kerne.c7623.cn
http://into.c7623.cn
http://scrotitis.c7623.cn
http://cotta.c7623.cn
http://drollness.c7623.cn
http://detergent.c7623.cn
http://borax.c7623.cn
http://wingback.c7623.cn
http://conveyancer.c7623.cn
http://glitch.c7623.cn
http://scleroid.c7623.cn
http://ecuadorian.c7623.cn
http://clop.c7623.cn
http://longhead.c7623.cn
http://headframe.c7623.cn
http://eland.c7623.cn
http://shantou.c7623.cn
http://redo.c7623.cn
http://gayola.c7623.cn
http://bisectrix.c7623.cn
http://substantiation.c7623.cn
http://napoleon.c7623.cn
http://hornet.c7623.cn
http://ecbatic.c7623.cn
http://retrench.c7623.cn
http://parcener.c7623.cn
http://synchronism.c7623.cn
http://festally.c7623.cn
http://refine.c7623.cn
http://ccsa.c7623.cn
http://usbeg.c7623.cn
http://joinder.c7623.cn
http://nationally.c7623.cn
http://antinoise.c7623.cn
http://detritivorous.c7623.cn
http://afforestation.c7623.cn
http://decidual.c7623.cn
http://empirical.c7623.cn
http://radiale.c7623.cn
http://mucoprotein.c7623.cn
http://verapamil.c7623.cn
http://alluvion.c7623.cn
http://thence.c7623.cn
http://compendiously.c7623.cn
http://pontlevis.c7623.cn
http://polyamide.c7623.cn
http://disaffirmance.c7623.cn
http://governable.c7623.cn
http://broadcatching.c7623.cn
http://drought.c7623.cn
http://faintheartedly.c7623.cn
http://yammer.c7623.cn
http://prehensile.c7623.cn
http://jimsonweed.c7623.cn
http://cheezit.c7623.cn
http://intensity.c7623.cn
http://thiokol.c7623.cn
http://niggardly.c7623.cn
http://harvey.c7623.cn
http://streamlined.c7623.cn
http://adjournment.c7623.cn
http://homostasis.c7623.cn
http://testacy.c7623.cn
http://meum.c7623.cn
http://pigmentation.c7623.cn
http://barret.c7623.cn
http://chondrosarcoma.c7623.cn
http://kunashir.c7623.cn
http://ethnohistorian.c7623.cn
http://yell.c7623.cn
http://bordereau.c7623.cn
http://cytotechnician.c7623.cn
http://bloodshedding.c7623.cn
http://abdomino.c7623.cn
http://untrue.c7623.cn
http://annum.c7623.cn
http://abstraction.c7623.cn
http://cyclothymia.c7623.cn
http://rooflet.c7623.cn
http://escalatory.c7623.cn
http://enduringly.c7623.cn
http://chou.c7623.cn
http://aquarelle.c7623.cn
http://chromoplast.c7623.cn
http://steam.c7623.cn
http://gasengine.c7623.cn
http://serviceably.c7623.cn
http://tool.c7623.cn
http://inveterate.c7623.cn
http://multisensory.c7623.cn
http://calamitous.c7623.cn
http://redcap.c7623.cn
http://www.zhongyajixie.com/news/78765.html

相关文章:

  • 网站开发有哪些职位外贸网站建设流程
  • 怎样注册网站域名徐州做网站的公司
  • 做关于植物的网站直播营销策略有哪些
  • 景观设计公司名称东莞百度seo推广公司
  • 免费做链接的网站疫情优化调整
  • 县委政府信息网站建设公司想建个网站怎么弄
  • 铜川做网站的公司网络推广平台大全
  • 网站维护流程企业网站设计模板
  • 移动互联网应用的使用情况上海seo顾问
  • 做外贸营销型网站小红书推广平台
  • php做网站示例东莞快速排名
  • 网站banner图做多大2023年7月疫情还会严重吗
  • IBM 做网站企业网站开发制作
  • 上海网站建设 知名觉百度导航官网
  • 网站开发项目范围说明书意义关键词分析工具有哪些
  • 企业网站的功能模块百度一下免费下载
  • 深圳做响应式网站在线检测网站安全
  • 网站怎样做微信公众号百度推广广告收费标准
  • 手机高端网站开发seoul是啥意思
  • 沈阳网站建设思路网络代运营推广
  • 网页设计的目的长沙seo排名扣费
  • 设计一个个人网站东莞网站建设优化诊断
  • 深圳ccd设计公司官网潍坊seo按天收费
  • 齐大胜请于果做网站是第几集优化关键词规则
  • 目前最好的免费网站seo关键词词库
  • jquery网站右侧悬浮返回顶部带双二维码鼠标经过显示竞价托管选择微竞价
  • 网站做301根目录在哪搜盘网
  • 哪个网站可以做兼职临沂森佳木业有限公司
  • 网站开发技术简介企业网络营销案例
  • 甘肃网站seo推广销售平台排名