LeetCode 高频 SQL 50 题(基础版)之 【连接】部分 · 上

题目:1378. 使用唯一标识码替换员工ID


题解:

sql 复制代码
select eu.unique_id,e.name from Employees e left join EmployeeUNI eu on e.id=eu.id

题目:1068. 产品销售分析 I



题解:

sql 复制代码
select p.product_name,s.year,s.price from Sales s,Product p 
where s.product_id = p.product_id 

题目:1581. 进店却未进行过交易的顾客




题解:

sql 复制代码
select customer_id,count(customer_id) as count_no_trans from Visits v left join Transactions t on v.visit_id=t.visit_id
where t.transaction_id is null 
group by customer_id
sql 复制代码
select customer_id,count(customer_id) as count_no_trans  from Visits 
where visit_id not in (select distinct visit_id from Transactions )
group by customer_id

题目:197. 上升的温度



题解:

sql 复制代码
select b.id as id from Weather a,Weather b 
where datediff(b.recordDate,a.recordDate)=1 and a.Temperature < b.Temperature

题目:1661. 每台机器的进程平均运行时间




题解:

sql 复制代码
select a.machine_id, round(avg(b.timestamp-a.timestamp),3) as processing_time  from Activity a,Activity b 
where a.machine_id=b.machine_id and a.process_id=b.process_id and a.activity_type='start' and b.activity_type='end'
group by a.machine_id
相关推荐
hey you~3 小时前
400电话选型技术测评:一个开发视角的线路质量评估方案
运维·网络·数据库·400电话·企业通信
Database_Cool_3 小时前
实时计数器/排行榜首选:阿里云 Tair 高并发数据结构实践
数据结构·数据库·阿里云·云计算
言乐63 小时前
Python视频相对亮度检测
数据库·python·计算机视觉·小程序·音视频
snow@li4 小时前
中台:中台即复用 / 理解企业架构中的能力抽象与分层共享 / 中台体系全景梳理 / 共性能力抽象、沉淀并复用
数据库
SelectDB技术团队4 小时前
AB 实验指标计算场景:Apache Doris / SelectDB 的技术能力、选型对比与实践
大数据·数据库·数据分析·apache·用户运营·apache doris·selectdb
snow@li4 小时前
数据库:B+ 树 / 数据库索引的底层支柱
数据库
梦想的旅途24 小时前
企业微信二次开发实战:基于RPA接口的私域中台架构设计与选型指南
数据库·企业微信·rpa
许彰午5 小时前
87_Python Django模型与数据库
数据库·python·django
—Miss. Z—5 小时前
计算机二级MySQL选择题考点Ⅱ
数据库·mysql·oracle
敖行客 Allthinker5 小时前
IM 融合专题:后端架构师的核心修炼
java·开发语言·数据库