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
目录
相关文章
|
11月前
|
存储 数据库
什么是数据库编程中的 Scalar Type
什么是数据库编程中的 Scalar Type
|
12月前
|
SQL 存储 数据库
sql数据库中的 delete 与drop的区别
sql数据库中的 delete 与drop的区别
235 1
|
1月前
|
存储 SQL 关系型数据库
关系型数据库sqlserver的DROP语句
【8月更文挑战第5天】
33 4
|
29天前
|
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的错误
|
4月前
|
关系型数据库 MySQL 数据库
关系型数据库DROP语句
`DROP` 语句用于永久删除数据库对象,如数据库、表、索引等,操作不可逆。在执行前需谨慎并备份数据。示例包括:删除表 `DROP TABLE 表名`,删除数据库 `DROP DATABASE 数据库名`,MySQL 中删除索引 `DROP INDEX 索引名 ON 表名`,删除视图 `DROP VIEW 视图名`,删除触发器 `DROP TRIGGER 触发器名`,以及可能的其他数据库对象。执行前请三思并确保有数据恢复措施。
36 2
|
SQL 数据可视化 数据库
怎么使用可视化数据库工具 DBeaver 在账单类型 type 表里添加数据?
怎么使用可视化数据库工具 DBeaver 在账单类型 type 表里添加数据?
475 0
怎么使用可视化数据库工具 DBeaver 在账单类型 type 表里添加数据?
|
数据库
数据库LeetCode每日练习(三)
数据库LeetCode每日练习(三)
数据库LeetCode每日练习(三)
|
SQL 数据库
数据库LeetCode每日练习(二)
数据库LeetCode每日练习(二)
数据库LeetCode每日练习(二)
|
SQL 数据库
数据库LeetCode每日练习(一)
数据库LeetCode每日练习(一)
数据库LeetCode每日练习(一)
|
Java 数据库连接 数据库
数据库类型与JDBC TYPE 和Java类型对应关系
数据库类型与JDBC TYPE 和Java类型对应关系