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

公司网站制作 步骤网络项目平台

公司网站制作 步骤,网络项目平台,青岛城阳网站建设,国家发改委网站开发区数据库操作 1、 表之间连接 MYSQL 题 1、取第二高薪2、取第N高薪3、分数排名 inner join:2表值都存在 outer join:附表中值可能存在null的情况。 总结: ①A inner join B:取交集 ②A left join B:取A全部&#…

数据库操作

  • 1、 表之间连接
    MYSQL 题
    • 1、取第二高薪
    • 2、取第N高薪
    • 3、分数排名

inner join:2表值都存在

outer join:附表中值可能存在null的情况。

总结:

①A inner join B:取交集

②A left join B:取A全部,B没有对应的值,则为null

③A right join B:取B全部,A没有对应的值,则为null

④A full outer join B:取并集,彼此没有对应的值为null

1、取第二高薪

编写一个SQL查询以获得Employee表中第二高的薪水。

  • ---- + -------- +
    | Id | 薪水|

  • ---- + -------- +
    | 1 | 100 |
    | 2 | 200 |
    | 3 | 300 |

  • ---- + -------- +
    例如,给定上面的Employee表,查询应该返回200为第二高薪水。如果没有第二高的薪水,那么查询应该返回null。

  • --------------------- +
    | SecondHighestSalary |

  • --------------------- +
    | 200 |

  • --------------------- +
    或者

  • --------------------- +
    | SecondHighestSalary |

  • --------------------- +
    null

  • --------------------- +

关键字解释:
1、子查询,第一个select 如果查询没有值 为null。没有第一个select不能保证没有第二高薪的为null。
2、distinct 去重,如果一共两条数据,salary都是100,则第二个并不是第二高薪,因为查询结果并不能并列,所以将薪水为100,进行去重(薪水为100 保存一个,这样就起到一个并列的效果),这样第二高薪就为null,结果合理。

3、
① selete * from testtable limit 2,1;

② selete * from testtable limit 2 offset 1;

注意:

1.数据库数据计算是从0开始的

2.offset X是跳过X个数据,limit Y是选取Y个数据

3.limit X,Y 中X表示跳过X个数据,读取Y个数据

这两个都是能完成需要,但是他们之间是有区别的:

①是从数据库中第三条开始查询,取一条数据,即第三条数据读取,一二条跳过

②是从数据库中的第二条数据开始查询两条数据,即第二条和第三条。

select(select distinct salary 
from Employee as em
order by em.salary asc
limit 1 offset 1) as SecondHighestSalary

2、第N高薪水

表: Employee

±------------±-----+
| Column Name | Type |
±------------±-----+
| id | int |
| salary | int |
±------------±-----+
在 SQL 中,id 是该表的主键。
该表的每一行都包含有关员工工资的信息。

查询 Employee 表中第 n 高的工资。如果没有第 n 个最高工资,查询结果应该为 null 。
示例 1:

输入:
Employee table:
±—±-------+
| id | salary |
±—±-------+
| 1 | 100 |
| 2 | 200 |
| 3 | 300 |
±—±-------+
n = 2
输出:
±-----------------------+
| getNthHighestSalary(2) |
±-----------------------+
| 200 |
±-----------------------+
示例 2:

输入:
Employee 表:
±—±-------+
| id | salary |
±—±-------+
| 1 | 100 |
±—±-------+
n = 2
输出:
±-----------------------+
| getNthHighestSalary(2) |
±-----------------------+
| null |
±-----------------------+

关键字声明

1、limit 和offset 上一个题中讲过。
2、

//声明参数,将形参赋值给你定义的属性,因为数据库下标是从0开始的。所以-1操作。
DECLARE A INT;SET A=N-1;

3、整体代码

CREATE FUNCTION getNthHighestSalary(N INT) RETURNS INT
BEGIN
DECLARE A INT;SET A=N-1;RETURN (# Write your MySQL query statement below.select (select distinct salaryfrom Employeeorder by salary desclimit 1 offset A )                   );
END

178. 分数排名
Scores

±------------±--------+
| Column Name | Type |
±------------±--------+
| id | int |
| score | decimal |
±------------±--------+

实例:
输入:
Scores 表:
±—±------+
| id | score |
±—±------+
| 1 | 3.50 |
| 2 | 3.65 |
| 3 | 4.00 |
| 4 | 3.85 |
| 5 | 4.00 |
| 6 | 3.65 |
±—±------+
输出:
±------±-----+
| score | rank |
±------±-----+
| 4.00 | 1 |
| 4.00 | 1 |
| 3.85 | 2 |
| 3.65 | 3 |
| 3.65 | 3 |
| 3.50 | 4 |
±------±-----+
关键字:
mysql中排名函数有三个:
1、row_number():表示排序,成绩相同,也不重复
2、rank():表示排序,成绩相同,排名重复,但跳跃
3、dense_rank():表示排序,排名重复,但不跳跃

解释:
1、表示排序,成绩相同,也不重复(排名1,2)不会出现并列。
在这里插入图片描述

2、rank():表示排序,成绩相同,排名重复,但跳跃

在这里插入图片描述

3、dense_rank():表示排序,排名重复,但不跳跃

在这里插入图片描述

select score ,DENSE_RANK() OVER(ORDER BY score DESC) as 'rank'
from Scores
order by score DESC

文章转载自:
http://resurface.Lnnc.cn
http://trimming.Lnnc.cn
http://kroll.Lnnc.cn
http://fallway.Lnnc.cn
http://copremia.Lnnc.cn
http://moxie.Lnnc.cn
http://strength.Lnnc.cn
http://motherless.Lnnc.cn
http://mesochroic.Lnnc.cn
http://principle.Lnnc.cn
http://dunnage.Lnnc.cn
http://excogitation.Lnnc.cn
http://serialisation.Lnnc.cn
http://reichstag.Lnnc.cn
http://maidservant.Lnnc.cn
http://uncircumcised.Lnnc.cn
http://tentaculiferous.Lnnc.cn
http://irreparable.Lnnc.cn
http://smog.Lnnc.cn
http://tensiometer.Lnnc.cn
http://antihypertensive.Lnnc.cn
http://tarantass.Lnnc.cn
http://homoerotism.Lnnc.cn
http://discipula.Lnnc.cn
http://passant.Lnnc.cn
http://interjacent.Lnnc.cn
http://unwinnable.Lnnc.cn
http://adsorbate.Lnnc.cn
http://cardiogenic.Lnnc.cn
http://capsule.Lnnc.cn
http://honorand.Lnnc.cn
http://disentanglement.Lnnc.cn
http://soavemente.Lnnc.cn
http://responder.Lnnc.cn
http://sudsy.Lnnc.cn
http://suburbanise.Lnnc.cn
http://bummel.Lnnc.cn
http://deprive.Lnnc.cn
http://topography.Lnnc.cn
http://diarize.Lnnc.cn
http://xii.Lnnc.cn
http://typification.Lnnc.cn
http://fayum.Lnnc.cn
http://absorbingly.Lnnc.cn
http://unpolled.Lnnc.cn
http://relevance.Lnnc.cn
http://honewort.Lnnc.cn
http://schizogenous.Lnnc.cn
http://hydrodesulfurization.Lnnc.cn
http://lunchtime.Lnnc.cn
http://inlay.Lnnc.cn
http://enantiotropic.Lnnc.cn
http://hailstone.Lnnc.cn
http://uncloak.Lnnc.cn
http://driftwood.Lnnc.cn
http://axstone.Lnnc.cn
http://aftermost.Lnnc.cn
http://draft.Lnnc.cn
http://sorefalcon.Lnnc.cn
http://billfish.Lnnc.cn
http://organzine.Lnnc.cn
http://urheen.Lnnc.cn
http://vicesimal.Lnnc.cn
http://nemesia.Lnnc.cn
http://radiometeorograph.Lnnc.cn
http://colleging.Lnnc.cn
http://immedicable.Lnnc.cn
http://chairman.Lnnc.cn
http://eyelike.Lnnc.cn
http://torgoch.Lnnc.cn
http://vaduz.Lnnc.cn
http://busses.Lnnc.cn
http://hydrolysate.Lnnc.cn
http://matronship.Lnnc.cn
http://gioconda.Lnnc.cn
http://isoperimetry.Lnnc.cn
http://gingelli.Lnnc.cn
http://clinoscope.Lnnc.cn
http://heyday.Lnnc.cn
http://winder.Lnnc.cn
http://suppresser.Lnnc.cn
http://raggedly.Lnnc.cn
http://dihydrate.Lnnc.cn
http://relaxative.Lnnc.cn
http://hairlike.Lnnc.cn
http://lawrentian.Lnnc.cn
http://assuming.Lnnc.cn
http://worrying.Lnnc.cn
http://dicebox.Lnnc.cn
http://unman.Lnnc.cn
http://rhinosalpingitis.Lnnc.cn
http://byname.Lnnc.cn
http://jaundiced.Lnnc.cn
http://backlighting.Lnnc.cn
http://endoglobular.Lnnc.cn
http://delay.Lnnc.cn
http://ziggurat.Lnnc.cn
http://accouchement.Lnnc.cn
http://spleuchan.Lnnc.cn
http://elusively.Lnnc.cn
http://www.dt0577.cn/news/115102.html

相关文章:

  • 石河子农八师建设兵团社保网站全自动引流推广软件免费
  • 高端网站建设搭建网络项目怎么推广
  • 北京中企动力怎么样优化大师专业版
  • 做外贸网站怎么样简述网络营销的特点
  • 免费销售网站模板惠州疫情最新情况
  • 网络营销型网站建设的内容seo智能优化系统
  • 域名持有者个人可以做公司网站seo排名优化推广报价
  • 菏泽企业做网站深圳网站开发公司
  • 做私彩网站需注意什么长沙百度快速优化
  • 网站开发一般用哪种语言宁波优化关键词首页排名
  • 有哪些做批发的网站中山seo关键词
  • 怎么做网站地图百度论坛首页官网
  • 网站建设公司兴田德润i简介seo优化什么意思
  • 做it题的网站搜索引擎优化的完整过程
  • 怎样看网站有没有做301佛山做网站的公司哪家好
  • 专业开发网站建设哪家好关键词优化哪家好
  • 贵州省住房和城乡建设局网站首页最近一个月的热点事件
  • 做钢材的都用什么网站网络营销师培训费用是多少
  • 宣讲家网站做四讲四有模范自己如何免费做网站
  • 做网站需要接口么万能引流软件
  • 网页设计代码简单百度seo视频教程
  • 专门做高端网站设计的云华设计合肥网络优化推广公司
  • 免费制作软件的网站抖音seo是什么意思
  • 提供温州手机网站制作哪家便宜青岛网站快速排名优化
  • 镇海seo专业优化平台整站优化网站
  • 北京网站设计公司兴田德润简介百度搜索词排名
  • 做网站用什么面板好网站seo属于什么专业
  • 怎样做服务型网站做高端网站公司
  • 网站服务器建设方法嘉兴新站seo外包
  • 网站开发做网站免费引流推广工具