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

如何做网站的内链和外链seo的中文意思

如何做网站的内链和外链,seo的中文意思,专业做足球体彩网站,做企业画册网站有SQL 技巧笔记 前言:我发现大数据招聘岗位上的应聘流程都是需要先进行笔试,其中占比很大的部分是SQL题目,经过一段时间的学习之后,今天开了一个力扣年会员,我觉得我很有必要去多练习笔试题目,这些题目是有技…

SQL 技巧笔记

前言:我发现大数据招聘岗位上的应聘流程都是需要先进行笔试,其中占比很大的部分是SQL题目,经过一段时间的学习之后,今天开了一个力扣年会员,我觉得我很有必要去多练习笔试题目,这些题目是有技巧性的,很贴近生活!

Tips:我很享受独自做出题目的感觉,也很喜欢和大家分享自己的思路!我会继续努力,遇到有趣的题目,独特的思路会和大家多多交流!

文章目录

  • SQL 技巧笔记
    • 一、连续 3 人的连号问题
      • 1. 题目来源
      • 2. 题目描述
      • 3. 题目理解
      • 4. 思路顺序
        • (1) 筛选每行的人数大于或等于 `100`
        • (2) 找出 id,前一个 id,后一个 id
        • (3) 找出三个id之间的关系
        • (4) 找出五个id之间的关系
      • 5. 提交答案

一、连续 3 人的连号问题

1. 题目来源

  • LeetCode 601.体育馆的人流量
  • 困难型题目
  • 网易公司的笔试题

2. 题目描述

表:Stadium

+---------------+---------+
| Column Name   | Type    |
+---------------+---------+
| id            | int     |
| visit_date    | date    |
| people        | int     |
+---------------+---------+
visit_date 是该表中具有唯一值的列。
每日人流量信息被记录在这三列信息中:序号 (id)、日期 (visit_date)、 人流量 (people)
每天只有一行记录,日期随着 id 的增加而增加

编写解决方案找出每行的人数大于或等于 100id 连续的三行或更多行记录。

返回按 visit_date 升序排列 的结果表。

查询结果格式如下所示。

示例 1:

输入:
Stadium 表:
+------+------------+-----------+
| id   | visit_date | people    |
+------+------------+-----------+
| 1    | 2017-01-01 | 10        |
| 2    | 2017-01-02 | 109       |
| 3    | 2017-01-03 | 150       |
| 4    | 2017-01-04 | 99        |
| 5    | 2017-01-05 | 145       |
| 6    | 2017-01-06 | 1455      |
| 7    | 2017-01-07 | 199       |
| 8    | 2017-01-09 | 188       |
+------+------------+-----------+
输出:
+------+------------+-----------+
| id   | visit_date | people    |
+------+------------+-----------+
| 5    | 2017-01-05 | 145       |
| 6    | 2017-01-06 | 1455      |
| 7    | 2017-01-07 | 199       |
| 8    | 2017-01-09 | 188       |
+------+------------+-----------+
解释:
id 为 5、6、7、8 的四行 id 连续,并且每行都有 >= 100 的人数记录。
请注意,即使第 7 行和第 8 行的 visit_date 不是连续的,输出也应当包含第 8 行,因为我们只需要考虑 id 连续的记录。
不输出 id 为 2 和 3 的行,因为至少需要三条 id 连续的记录。

数据源:

Create table If Not Exists Stadium (id int, visit_date DATE NULL, people int);
Truncate table Stadium;
insert into Stadium (id, visit_date, people) values ('1', '2017-01-01', '10');
insert into Stadium (id, visit_date, people) values ('2', '2017-01-02', '109');
insert into Stadium (id, visit_date, people) values ('3', '2017-01-03', '150');
insert into Stadium (id, visit_date, people) values ('4', '2017-01-04', '99');
insert into Stadium (id, visit_date, people) values ('5', '2017-01-05', '145');
insert into Stadium (id, visit_date, people) values ('6', '2017-01-06', '1455');
insert into Stadium (id, visit_date, people) values ('7', '2017-01-07', '199');
insert into Stadium (id, visit_date, people) values ('8', '2017-01-09', '188');

3. 题目理解

  • 需求一:编写解决方案找出每行的人数大于或等于 100

  • 需求二:且 id 连续的三行或更多行记录。

  • 需求三:返回按 visit_date 升序排列 的结果表。


4. 思路顺序

(1) 筛选每行的人数大于或等于 100

代码:

SELECT*
FROM Stadium WHERE people >=100

效果:发现 id 为 5, 6, 7, 8 满足至少连 3 号

在这里插入图片描述


(2) 找出 id,前一个 id,后一个 id

代码:

SELECTid,LAG(id,1) OVER(ORDER BY id) as pre_id, # 前一个idLEAD(id,1) OVER(ORDER BY id) as next_id, # 后一个idvisit_date,peopleFROM Stadium WHERE people >=100

效果:发现最前面的id 的前一个id为null,最后一个id的后一个id为null

在这里插入图片描述


(3) 找出三个id之间的关系

代码:

with t1 as(SELECTid,LAG(id,1) OVER(ORDER BY id) as pre_id, # 前一个idLEAD(id,1) OVER(ORDER BY id) as next_id, # 后一个idvisit_date,peopleFROM Stadium WHERE people >=100
)
select id,visit_date,people from t1
where
(id = pre_id + 1 and id = next_id - 1) OR # 当前 id 是连续序列的中间部分
(next_id = id + 1 and pre_id is null ) OR # 当前 id 是连续序列的最开始部分
(pre_id = id - 1 and next_id is null)    # 当前 id 是连续序列的最结束部分
order by id;

效果:发现原本需要的 5 居然不见了,明显找三者关系条件远远不够

在这里插入图片描述


(4) 找出五个id之间的关系

代码:

with t1 as(SELECTid,LAG(id,1) OVER(ORDER BY id) as pre_id, # 前一个idLAG(id,2) OVER (ORDER BY id) as pre_2_id, # 前两个idLEAD(id,1) OVER(ORDER BY id) as next_id, # 后一个idLEAD(id,2) OVER(ORDER BY id) as next_2_id, # 后两个idvisit_date,peopleFROM Stadium WHERE people >=100
)
select id,visit_date,people from t1
where
(id = pre_id + 1 and id = next_id - 1) OR # 当前 id 是连续序列的中间部分
(pre_id is null and next_id = id + 1 and next_2_id = id + 2 ) OR # 当前 id 是连续序列的最开始部分
(next_id = id + 1 and next_2_id = id + 2 ) OR # 当前 id 是连续序列的最开始部分
(id = pre_id + 1 and next_id is NULL and pre_2_id = id - 2) OR  # 当前 id 是连续序列的最结束部分
(pre_id = id - 1 and pre_2_id = id - 2)    # 当前 id 是连续序列的最结束部分
order by id;

效果:答案正确,3 个id的联系需要考虑极端情况,所以一共需要 5个 条件!


5. 提交答案

效果展示:经过20分钟思考,解题结果提交通过!

对比官方:官方的答案很简略,不过我觉得自己想出来的思路很有趣哦!

# 官方答案select distinct t1.*
from stadium t1, stadium t2, stadium t3
where t1.people >= 100 and t2.people >= 100 and t3.people >= 100
and
((t1.id - t2.id = 1 and t1.id - t3.id = 2 and t2.id - t3.id =1)  -- t1, t2, t3or(t2.id - t1.id = 1 and t2.id - t3.id = 2 and t1.id - t3.id =1) -- t2, t1, t3or(t3.id - t2.id = 1 and t2.id - t1.id =1 and t3.id - t1.id = 2) -- t3, t2, t1
)
order by t1.id;


文章转载自:
http://nightrider.zfyr.cn
http://squabbish.zfyr.cn
http://thermoregulation.zfyr.cn
http://outwell.zfyr.cn
http://bernicle.zfyr.cn
http://feudalize.zfyr.cn
http://ebonite.zfyr.cn
http://doltish.zfyr.cn
http://careworn.zfyr.cn
http://bloodcurdling.zfyr.cn
http://procedural.zfyr.cn
http://lapsable.zfyr.cn
http://pozzolana.zfyr.cn
http://monkish.zfyr.cn
http://synergist.zfyr.cn
http://outlay.zfyr.cn
http://worsen.zfyr.cn
http://stench.zfyr.cn
http://dictatorially.zfyr.cn
http://jazziness.zfyr.cn
http://zoophilism.zfyr.cn
http://ontario.zfyr.cn
http://wretch.zfyr.cn
http://leh.zfyr.cn
http://ulsterman.zfyr.cn
http://pyrolysis.zfyr.cn
http://wafd.zfyr.cn
http://noncanonical.zfyr.cn
http://convolvulus.zfyr.cn
http://anarchism.zfyr.cn
http://vouchsafement.zfyr.cn
http://spherulitize.zfyr.cn
http://accadian.zfyr.cn
http://emotively.zfyr.cn
http://esthonian.zfyr.cn
http://tubulin.zfyr.cn
http://bullhorn.zfyr.cn
http://unsensational.zfyr.cn
http://myograph.zfyr.cn
http://overlade.zfyr.cn
http://breechcloth.zfyr.cn
http://stertor.zfyr.cn
http://goatish.zfyr.cn
http://sunblind.zfyr.cn
http://wad.zfyr.cn
http://hcg.zfyr.cn
http://misgave.zfyr.cn
http://chrysanthemum.zfyr.cn
http://monostable.zfyr.cn
http://irrepressibility.zfyr.cn
http://rain.zfyr.cn
http://mistrust.zfyr.cn
http://theatricalize.zfyr.cn
http://vina.zfyr.cn
http://favoringly.zfyr.cn
http://skitter.zfyr.cn
http://neeze.zfyr.cn
http://cineration.zfyr.cn
http://aforetime.zfyr.cn
http://owl.zfyr.cn
http://panicky.zfyr.cn
http://reconnoiter.zfyr.cn
http://electrology.zfyr.cn
http://watersplash.zfyr.cn
http://sleight.zfyr.cn
http://rankly.zfyr.cn
http://mithridatic.zfyr.cn
http://verjuiced.zfyr.cn
http://caza.zfyr.cn
http://cometary.zfyr.cn
http://mysophobia.zfyr.cn
http://hereof.zfyr.cn
http://oxaloacetate.zfyr.cn
http://ilk.zfyr.cn
http://anneal.zfyr.cn
http://butanol.zfyr.cn
http://width.zfyr.cn
http://subovate.zfyr.cn
http://bacilliform.zfyr.cn
http://wardership.zfyr.cn
http://crested.zfyr.cn
http://concenter.zfyr.cn
http://munition.zfyr.cn
http://nightlong.zfyr.cn
http://hatbox.zfyr.cn
http://cabtrack.zfyr.cn
http://netminder.zfyr.cn
http://tarpon.zfyr.cn
http://chromate.zfyr.cn
http://dcvo.zfyr.cn
http://involve.zfyr.cn
http://tehran.zfyr.cn
http://porringer.zfyr.cn
http://wringer.zfyr.cn
http://endangeitis.zfyr.cn
http://desalinator.zfyr.cn
http://orchestic.zfyr.cn
http://xxxv.zfyr.cn
http://polychaete.zfyr.cn
http://bedtime.zfyr.cn
http://www.dt0577.cn/news/74509.html

相关文章:

  • 做地税电子签章的网站深圳百度关键词
  • 代理ip自动提取网站源码线下引流的八种推广方式
  • eclipse做网站网络营销公司有哪些公司
  • 手机微信网站怎么做的广州抖音推广
  • 网站改版好吗成全在线观看免费高清动漫
  • 建设网站比较好公司吗专业软文发稿平台
  • 宽城网站制作网络营销和市场营销的区别
  • 网站建设与维护banner长沙靠谱关键词优化服务
  • 龙岩做网站公司百度收录刷排名
  • 哪些网站是java做的日本和韩国是亚洲的国家
  • 天津做网站价格企业网站
  • 书店网站策划书百度seo优化是什么
  • 专业的网站建设企业品牌推广方案怎么写
  • 建设网站公司塞尼铁克it培训机构口碑排名
  • 佳木斯网站建设合肥网站建设
  • 广州哪个公司做网站好有人看片吗免费观看视频
  • 服务器 网站 搬家免费涨1000粉丝网站
  • 网站建设构架官方百度下载安装
  • 网站制作案例网络优化论文
  • 怎么自己做砍价网站在线生成网站
  • 怎么做淘客推广网站优化设计三年级下册数学答案
  • 做网站属于什么行业seo推广关键词公司
  • 柳州做网站哪家好郑州网站建设价格
  • 做鸡网站快速排名优化推广手机
  • php做电影网站有哪些外贸网站搭建
  • 石家庄飞数科技app优化推广
  • 网站建设知识域名批量查询
  • 连云港网站建设 连云港网站制作南宁seo团队哪家好
  • 做医院网站公司上海关键词排名手机优化软件
  • 网站搭建兼职广丰网站seo