LeetCode(数据库)- Drop Type 1 Orders for Customers With Type 0 Orders

简介: LeetCode(数据库)- Drop Type 1 Orders for Customers With Type 0 Orders

题目链接:点击打开链接

题目大意:略。

解题思路:略。

AC 代码

-- 解决方案(1)
select distinct a.order_id, a.customer_id, a.order_type from Orders as a left join Orders as b
on a.customer_id = b.customer_id and a.order_type <> b.order_type
where b.order_type is null or b.order_type = 1
-- 解决方案(2)
WITH t0 AS(SELECT * FROM Orders WHERE order_type = 0)
SELECT * 
FROM Orders
WHERE order_type = 1 AND customer_id NOT IN (SELECT customer_id FROM t0)
UNION ALL
SELECT * FROM t0
目录
相关文章
|
SQL 存储 数据库
sql数据库中的 delete 与drop的区别
sql数据库中的 delete 与drop的区别
866 1
|
关系型数据库 MySQL 数据库
对于mysql数据库delect from,truncate table,drop table, update操作的时候如何选择
对于mysql数据库delect from,truncate table,drop table, update操作的时候如何选择
703 2
|
11月前
|
数据管理 分布式数据库 数据库
循序渐进丨MogDB 数据库v5.0之闪回DROP/TRUNCATE
MogDB v5.0中的闪回DROP/TRUNCATE功能为数据库管理提供了强大的数据恢复能力。通过撤销日志和版本控制机制,能够高效地恢复误操作导致的数据丢失。这一功能不仅提高了数据管理的灵活性和安全性,还简化了日常维护工作。希望本文能帮助读者深入理解和应用MogDB的闪回功能,提高数据库管理效率。
142 15
|
10月前
|
数据库
【YashanDB数据库】YAS-02032 column type is incompatible with referenced column type
YAS-02032 column type is incompatible with referenced column type
|
存储 SQL 关系型数据库
关系型数据库sqlserver的DROP语句
【8月更文挑战第5天】
395 4
|
SQL 数据库 Windows
【应用服务 App Service】当使用EntityFrameWorkCore访问Sql Server数据库时,在Azure App Service会出现Cannot create a DbSet for ** because this type is not included in the model for the context的错误
【应用服务 App Service】当使用EntityFrameWorkCore访问Sql Server数据库时,在Azure App Service会出现Cannot create a DbSet for ** because this type is not included in the model for the context的错误
218 0
|
关系型数据库 MySQL 数据库
关系型数据库DROP语句
`DROP` 语句用于永久删除数据库对象,如数据库、表、索引等,操作不可逆。在执行前需谨慎并备份数据。示例包括:删除表 `DROP TABLE 表名`,删除数据库 `DROP DATABASE 数据库名`,MySQL 中删除索引 `DROP INDEX 索引名 ON 表名`,删除视图 `DROP VIEW 视图名`,删除触发器 `DROP TRIGGER 触发器名`,以及可能的其他数据库对象。执行前请三思并确保有数据恢复措施。
288 2
|
SQL 数据可视化 数据库
怎么使用可视化数据库工具 DBeaver 在账单类型 type 表里添加数据?
怎么使用可视化数据库工具 DBeaver 在账单类型 type 表里添加数据?
696 0
怎么使用可视化数据库工具 DBeaver 在账单类型 type 表里添加数据?
|
数据库
数据库LeetCode每日练习(三)
数据库LeetCode每日练习(三)
数据库LeetCode每日练习(三)
|
SQL 数据库
数据库LeetCode每日练习(二)
数据库LeetCode每日练习(二)
数据库LeetCode每日练习(二)

热门文章

最新文章