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
相关推荐
倔强的石头_几秒前
Oracle 迁移 TCO 深度拆解:从隐性运维成本陷阱到全栈工具链破局
数据库
2501_924952698 分钟前
Python深度学习入门:TensorFlow 2.0/Keras实战
jvm·数据库·python
2401_8914821710 分钟前
Python多线程与多进程:如何选择?(GIL全局解释器锁详解)
jvm·数据库·python
Predestination王瀞潞10 分钟前
6.3.1 软件->W3C XPath 1.0 标准(W3C Recommendation):XPath(XML Path Language)查询语言
xml·数据库·oracle
2401_8512729911 分钟前
用Python实现自动化的Web测试(Selenium)
jvm·数据库·python
快乐柠檬不快乐17 分钟前
Java连接电科金仓数据库(KingbaseES)实战指南
java·开发语言·数据库
AllData公司负责人27 分钟前
AllData数据中台通过集成DolphinScheduler+Seatunnel实现SAP HANA数据库同步到Doris数据仓库
数据库·数据仓库·sap hana
2401_8463416527 分钟前
使用Python进行网络设备自动配置
jvm·数据库·python
Q741_14730 分钟前
力扣高频面试题详解 数组 链表 力扣 56.合并区间 力扣 160.相交链表 C++ 每日练习
c++·算法·leetcode·链表·数组·哈希
执笔画情ora41 分钟前
Postgresql管理-杀会话还是取消会话?
数据库·oracle