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
相关推荐
小羊在睡觉21 小时前
力扣84. 柱状图中最大的矩形
后端·算法·leetcode·golang·go
ccddsdsdfsdf21 小时前
DBeaver怎么链接mongoDB
数据库·mongodb
sheeta19981 天前
LeetCode 每日一题笔记 日期:2026.05.29 题目:3300. 最小元素
笔记·leetcode
_日拱一卒1 天前
LeetCode:994腐烂的橘子
java·数据结构·算法·leetcode·深度优先
丷丩1 天前
Postgresql基础实践教程(十一)各种Join
数据库·postgresql·join
星夜夏空991 天前
FreeRTOS学习(4)——内存映射
数据库·学习·mongodb
TheRouter1 天前
AI Agent 记忆体系建设实战:短期、长期与工作记忆的工程实现
数据库·人工智能·oracle
Omics Pro1 天前
首个!外源天然产物综合性代谢图谱
数据库·人工智能·算法·机器学习·r语言
唐青枫1 天前
MySQL EXISTS 详解:存在性判断、NOT EXISTS 与实战示例
sql·mysql
JAVA面经实录9171 天前
Hibernate面试题库
数据库·oracle·hibernate