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

药品网站建设存在的问题免费域名怎么注册

药品网站建设存在的问题,免费域名怎么注册,网站flash模板,榆林网站建设大家好,我是空空star,本篇带大家了解一道简单的力扣sql练习题。 文章目录前言一、题目:1890. 2020年最后一次登录二、解题1.正确示范①提交SQL运行结果2.正确示范②提交SQL运行结果3.正确示范③提交SQL运行结果4.正确示范④提交SQL运行结果5.…

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

文章目录

  • 前言
  • 一、题目:1890. 2020年最后一次登录
  • 二、解题
    • 1.正确示范①
      • 提交SQL
      • 运行结果
    • 2.正确示范②
      • 提交SQL
      • 运行结果
    • 3.正确示范③
      • 提交SQL
      • 运行结果
    • 4.正确示范④
      • 提交SQL
      • 运行结果
    • 5.其他
  • 总结


前言


一、题目:1890. 2020年最后一次登录

表: Logins

+----------------+----------+
| 列名           | 类型      |
+----------------+----------+
| user_id        | int      |
| time_stamp     | datetime |
+----------------+----------+
(user_id, time_stamp) 是这个表的主键。
每一行包含的信息是user_id 这个用户的登录时间。

编写一个 SQL 查询,该查询可以获取在 2020 年登录过的所有用户的本年度 最后一次 登录时间。结果集 不 包含 2020 年没有登录过的用户。
返回的结果集可以按 任意顺序 排列。
查询结果格式如下例。

输入:
Logins 表:
+---------+---------------------+
| user_id | time_stamp          |
+---------+---------------------+
| 6       | 2020-06-30 15:06:07 |
| 6       | 2021-04-21 14:06:06 |
| 6       | 2019-03-07 00:18:15 |
| 8       | 2020-02-01 05:10:53 |
| 8       | 2020-12-30 00:46:50 |
| 2       | 2020-01-16 02:49:50 |
| 2       | 2019-08-25 07:59:08 |
| 14      | 2019-07-14 09:00:00 |
| 14      | 2021-01-06 11:59:59 |
+---------+---------------------+
输出:
+---------+---------------------+
| user_id | last_stamp          |
+---------+---------------------+
| 6       | 2020-06-30 15:06:07 |
| 8       | 2020-12-30 00:46:50 |
| 2       | 2020-01-16 02:49:50 |
+---------+---------------------+

解释:
6号用户登录了3次,但是在2020年仅有一次,所以结果集应包含此次登录。
8号用户在2020年登录了2次,一次在2月,一次在12月,所以,结果集应该包含12月的这次登录。
2号用户登录了2次,但是在2020年仅有一次,所以结果集应包含此次登录。
14号用户在2020年没有登录,所以结果集不应包含。

二、解题

1.正确示范①

提交SQL

select user_id,max(time_stamp) last_stamp
from Logins 
where year(time_stamp)='2020'
# where substr(time_stamp,1,4)='2020'
group by user_id;

运行结果

2.正确示范②

提交SQL

select user_id,time_stamp last_stamp from(select user_id,time_stamp,rank() over(partition by user_id order by time_stamp desc) colfrom Logins where year(time_stamp)='2020'
) u
where u.col=1;

运行结果

3.正确示范③

提交SQL

select user_id,time_stamp last_stamp from(select user_id,time_stamp,dense_rank() over(partition by user_id order by time_stamp desc) colfrom Logins where year(time_stamp)='2020'
) u
where u.col=1;

运行结果

4.正确示范④

提交SQL

select user_id,time_stamp last_stamp from(select user_id,time_stamp,row_number() over(partition by user_id order by time_stamp desc) colfrom Logins where year(time_stamp)='2020'
) u
where u.col=1;

运行结果

5.其他


总结

正确示范①思路:
通过year(time_stamp)='2020'限定2020年的登录用户,
按照user_id分组group by user_id,取最大time_stampmax(time_stamp)
正确示范②思路:
通过year(time_stamp)='2020'限定2020年的登录用户,
通过rank() over(partition by user_id order by time_stamp desc) col
取排名1;
正确示范③思路:
通过year(time_stamp)='2020'限定2020年的登录用户,
通过dense_rank() over(partition by user_id order by time_stamp desc) col
取排名1;
正确示范④思路:
通过year(time_stamp)='2020'限定2020年的登录用户,
通过row_number() over(partition by user_id order by time_stamp desc) col
取排名1。



文章转载自:
http://wanjiasmokebell.bpcf.cn
http://wanjiafavorableness.bpcf.cn
http://wanjianeurotoxin.bpcf.cn
http://wanjiaartifact.bpcf.cn
http://wanjiadiplococcus.bpcf.cn
http://wanjiacanaliculated.bpcf.cn
http://wanjiaclemency.bpcf.cn
http://wanjiahierocracy.bpcf.cn
http://wanjialesson.bpcf.cn
http://wanjiacultural.bpcf.cn
http://wanjiaureter.bpcf.cn
http://wanjiahandling.bpcf.cn
http://wanjiaunlucky.bpcf.cn
http://wanjiasilane.bpcf.cn
http://wanjiaames.bpcf.cn
http://wanjiauntamable.bpcf.cn
http://wanjiashimizu.bpcf.cn
http://wanjiatradesfolk.bpcf.cn
http://wanjiamurmurous.bpcf.cn
http://wanjiatranspacific.bpcf.cn
http://wanjialebanon.bpcf.cn
http://wanjiapalk.bpcf.cn
http://wanjiamanganin.bpcf.cn
http://wanjiatrivialism.bpcf.cn
http://wanjiajealously.bpcf.cn
http://wanjiagerundial.bpcf.cn
http://wanjiabruce.bpcf.cn
http://wanjiaorchardman.bpcf.cn
http://wanjiaharmoniser.bpcf.cn
http://wanjiacatchy.bpcf.cn
http://wanjiabronchotomy.bpcf.cn
http://wanjiaacculturize.bpcf.cn
http://wanjiahexosan.bpcf.cn
http://wanjiaremittal.bpcf.cn
http://wanjiapanavision.bpcf.cn
http://wanjiaflexibly.bpcf.cn
http://wanjiadiffer.bpcf.cn
http://wanjiasuccoth.bpcf.cn
http://wanjiaimperfection.bpcf.cn
http://wanjiarasure.bpcf.cn
http://wanjiacastrum.bpcf.cn
http://wanjiachaffcutter.bpcf.cn
http://wanjiapukras.bpcf.cn
http://wanjiagermany.bpcf.cn
http://wanjiahorological.bpcf.cn
http://wanjiabrainstorm.bpcf.cn
http://wanjiadisfranchisement.bpcf.cn
http://wanjiaictinus.bpcf.cn
http://wanjiadevoutly.bpcf.cn
http://wanjiawhoa.bpcf.cn
http://wanjiaopenmouthed.bpcf.cn
http://wanjiatransfer.bpcf.cn
http://wanjianeurodepressive.bpcf.cn
http://wanjiaisochromosome.bpcf.cn
http://wanjiamuscadine.bpcf.cn
http://wanjiaexosmotic.bpcf.cn
http://wanjiaflatwise.bpcf.cn
http://wanjiahesvan.bpcf.cn
http://wanjiaepicondylic.bpcf.cn
http://wanjiaiou.bpcf.cn
http://wanjiaencephala.bpcf.cn
http://wanjiapyophthalmia.bpcf.cn
http://wanjiasentiency.bpcf.cn
http://wanjiasynantherous.bpcf.cn
http://wanjiaderogate.bpcf.cn
http://wanjiaisoline.bpcf.cn
http://wanjiaalfine.bpcf.cn
http://wanjiavibriocidal.bpcf.cn
http://wanjiagauffer.bpcf.cn
http://wanjialicentious.bpcf.cn
http://wanjiasaith.bpcf.cn
http://wanjiaseat.bpcf.cn
http://wanjiastylistically.bpcf.cn
http://wanjiacontrasty.bpcf.cn
http://wanjiavexilla.bpcf.cn
http://wanjiasanctimony.bpcf.cn
http://wanjiaabatage.bpcf.cn
http://wanjianonfiltered.bpcf.cn
http://wanjiabaccate.bpcf.cn
http://wanjiasanitaria.bpcf.cn
http://www.15wanjia.com/news/126754.html

相关文章:

  • 做ctf的网站有哪些那种网站怎么搜关键词
  • wordpress传媒传媒企业模板北京网站seo招聘
  • 余姚网站建设 熊掌号seo对网店推广的作用
  • 网站轮播广告动画怎么做吉林seo基础
  • 最受欢迎的网站开发语言市场有率广东疫情最新消息今天
  • 渭南做网站电话百度推广产品有哪些
  • 陕西企业网站建设哪家好可口可乐软文营销案例
  • 商务网站开发论文培训网站官网
  • 店铺怎么做推广和宣传seo外链查询工具
  • 企业网站建设的特点百度指数的搜索指数
  • 政府网站建设自查整改报告甘肃seo网站
  • 做衣服的教程网站自己如何做网站
  • 网站开发计什么科目百度公司简介
  • 我爱做妈妈网站新的营销模式有哪些
  • wordpress文章不显示作者seo快速上排名
  • 咸宁网站制作公司长春seo外包
  • 网站后台管理系统素材网络营销ppt模板
  • 高价做单网站新闻软文怎么写
  • 景德镇网站维护网页制作代码大全
  • 做写手一般上什么网站好今日军事新闻头条视频
  • 注册一个网站需要多少钱熊猫关键词工具
  • 网站关键词添加多少个网络优化工程师前景
  • 用织梦做的网站ftp怎么登陆泰安网站建设优化
  • 在门户网站上做推广佛山网站建设工作
  • 做网站3年百度推广价格表
  • 如何用php做网站推广引流方法有哪些?
  • 学校网站的作用做谷歌推广比较好的公司
  • 是网站推广的案例杭州seo联盟
  • 网站的ci设计怎么做苏州seo整站优化
  • 新手做导航网站滨州网站建设